Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: src/heap.cc

Issue 10639002: Adjust idle notification handler to do full GC at the end of idle round in order to compact code sp… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4996 matching lines...) Expand 10 before | Expand all | Expand 10 after
5007 gc_count_at_last_idle_gc_ = gc_count_; 5007 gc_count_at_last_idle_gc_ = gc_count_;
5008 if (uncommit) { 5008 if (uncommit) {
5009 new_space_.Shrink(); 5009 new_space_.Shrink();
5010 UncommitFromSpace(); 5010 UncommitFromSpace();
5011 } 5011 }
5012 } 5012 }
5013 } 5013 }
5014 5014
5015 5015
5016 bool Heap::IdleNotification(int hint) { 5016 bool Heap::IdleNotification(int hint) {
5017 // Hints greater than this value indicate that
5018 // the embedder is requesting a lot of GC work.
5017 const int kMaxHint = 1000; 5019 const int kMaxHint = 1000;
5020 // Minimal hint that allows to do full GC.
5021 const int kMinHintForFullGC = 100;
5018 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; 5022 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4;
5019 // The size factor is in range [5..250]. The numbers here are chosen from 5023 // The size factor is in range [5..250]. The numbers here are chosen from
5020 // experiments. If you changes them, make sure to test with 5024 // experiments. If you changes them, make sure to test with
5021 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* 5025 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.*
5022 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; 5026 intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold;
5023 5027
5024 if (contexts_disposed_ > 0) { 5028 if (contexts_disposed_ > 0) {
5025 if (hint >= kMaxHint) { 5029 if (hint >= kMaxHint) {
5026 // The embedder is requesting a lot of GC work after context disposal, 5030 // The embedder is requesting a lot of GC work after context disposal,
5027 // we age inline caches so that they don't keep objects from 5031 // we age inline caches so that they don't keep objects from
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5075 StartIdleRound(); 5079 StartIdleRound();
5076 } else { 5080 } else {
5077 return true; 5081 return true;
5078 } 5082 }
5079 } 5083 }
5080 5084
5081 int new_mark_sweeps = ms_count_ - ms_count_at_last_idle_notification_; 5085 int new_mark_sweeps = ms_count_ - ms_count_at_last_idle_notification_;
5082 mark_sweeps_since_idle_round_started_ += new_mark_sweeps; 5086 mark_sweeps_since_idle_round_started_ += new_mark_sweeps;
5083 ms_count_at_last_idle_notification_ = ms_count_; 5087 ms_count_at_last_idle_notification_ = ms_count_;
5084 5088
5085 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { 5089 int remaining_mark_sweeps = kMaxMarkSweepsInIdleRound -
5090 mark_sweeps_since_idle_round_started_;
5091
5092 if (remaining_mark_sweeps <= 0) {
5086 FinishIdleRound(); 5093 FinishIdleRound();
5087 return true; 5094 return true;
5088 } 5095 }
5089 5096
5090 if (incremental_marking()->IsStopped()) { 5097 if (incremental_marking()->IsStopped()) {
5091 incremental_marking()->Start(); 5098 // If there are no more than two GCs left in this idle round and we are
5099 // allowed to do a full GC, then make those GCs full in order to compact
5100 // the code space. Once we enable code compaction for incremental marking,
Michael Starzinger 2012/06/21 16:24:12 Maybe mark the second sentence as a TODO, to empha
ulan 2012/06/22 08:15:57 Done.
5101 // we can get rid of this special case and always start incremental marking.
5102 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC){
5103 CollectAllGarbage(kReduceMemoryFootprintMask,
5104 "idle notification: finalize idle round");
5105 } else {
5106 incremental_marking()->Start();
5107 }
5092 } 5108 }
5093 5109 if (!incremental_marking()->IsStopped()) {
5094 AdvanceIdleIncrementalMarking(step_size); 5110 AdvanceIdleIncrementalMarking(step_size);
5111 }
5095 return false; 5112 return false;
5096 } 5113 }
5097 5114
5098 5115
5099 bool Heap::IdleGlobalGC() { 5116 bool Heap::IdleGlobalGC() {
5100 static const int kIdlesBeforeScavenge = 4; 5117 static const int kIdlesBeforeScavenge = 4;
5101 static const int kIdlesBeforeMarkSweep = 7; 5118 static const int kIdlesBeforeMarkSweep = 7;
5102 static const int kIdlesBeforeMarkCompact = 8; 5119 static const int kIdlesBeforeMarkCompact = 8;
5103 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1; 5120 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1;
5104 static const unsigned int kGCsBetweenCleanup = 4; 5121 static const unsigned int kGCsBetweenCleanup = 4;
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
7149 } else { 7166 } else {
7150 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died. 7167 p ^= 0x1d1ed & (Page::kPageSize - 1); // I died.
7151 } 7168 }
7152 remembered_unmapped_pages_[remembered_unmapped_pages_index_] = 7169 remembered_unmapped_pages_[remembered_unmapped_pages_index_] =
7153 reinterpret_cast<Address>(p); 7170 reinterpret_cast<Address>(p);
7154 remembered_unmapped_pages_index_++; 7171 remembered_unmapped_pages_index_++;
7155 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages; 7172 remembered_unmapped_pages_index_ %= kRememberedUnmappedPages;
7156 } 7173 }
7157 7174
7158 } } // namespace v8::internal 7175 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698