Chromium Code Reviews| Index: src/heap.h |
| diff --git a/src/heap.h b/src/heap.h |
| index f488b8cda276316df11e6df8b3e645a533c8b111..683cb966a813c9e15f52f403eab61606310bf0f8 100644 |
| --- a/src/heap.h |
| +++ b/src/heap.h |
| @@ -1268,8 +1268,8 @@ class Heap { |
| return Min(limit, halfway_to_the_max); |
| } |
| - // Can be called when the embedding application is idle. |
| - bool IdleNotification(); |
| + // Implements the corresponding V8 API function. |
| + bool IdleNotification(int hint); |
| // Declare all the root indices. |
| enum RootListIndex { |
| @@ -1392,6 +1392,17 @@ class Heap { |
| return &incremental_marking_; |
| } |
| + bool IsSweepingComplete() { |
| + return old_data_space()->IsSweepingComplete() && |
| + old_pointer_space()->IsSweepingComplete(); |
| + } |
| + |
| + bool AdvanceSweepers(int step_size) { |
| + bool sweeping_complete = old_data_space()->AdvanceSweeper(step_size); |
| + sweeping_complete &= old_pointer_space()->AdvanceSweeper(step_size); |
| + return sweeping_complete; |
| + } |
| + |
| ExternalStringTable* external_string_table() { |
| return &external_string_table_; |
| } |
| @@ -1427,6 +1438,10 @@ class Heap { |
| // The roots that have an index less than this are always in old space. |
| static const int kOldSpaceRoots = 0x20; |
| + bool idle_notification_will_schedule_next_gc() { |
| + return idle_notification_will_schedule_next_gc_; |
| + } |
| + |
| private: |
| Heap(); |
| @@ -1752,6 +1767,37 @@ class Heap { |
| void SelectScavengingVisitorsTable(); |
| + void StartIdleRound() { |
| + mark_sweeps_since_idle_round_started_ = 0; |
| + ms_count_at_last_idle_notification_ = ms_count_; |
| + } |
| + |
| + void FinishIdleRound() { |
| + mark_sweeps_since_idle_round_started_ = kMaxMarkSweepsInIdleRound; |
| + gc_count_when_last_idle_round_finished_ = gc_count_; |
| + } |
| + |
| + bool EnoughGarbageSinceLastIdleRound() { |
| + return (gc_count_ - gc_count_when_last_idle_round_finished_ > 4); |
|
ulan
2011/11/11 13:27:26
We agreed to count only scavenges here, but for th
Erik Corry
2011/11/14 23:05:17
I really think we should just add the extra counte
ulan
2011/11/15 09:08:43
Done.
|
| + } |
| + |
| + bool WorthStartingGCWhenIdle() { |
| + if (contexts_disposed_ > 0) { |
| + return true; |
| + } |
| + if (mark_sweeps_since_idle_round_started_ < kMaxMarkSweepsInIdleRound) { |
| + return incremental_marking()->WorthActivating(); |
| + } |
| + if (EnoughGarbageSinceLastIdleRound()) { |
| + return incremental_marking()->WorthActivating() && |
| + NextGCIsLikelyToBeFull(); |
| + } |
| + return false; |
| + } |
| + |
| + // Returns true if no more GC work is left. |
| + bool IdleGlobalGC(); |
| + |
| static const int kInitialSymbolTableSize = 2048; |
| static const int kInitialEvalCacheSize = 64; |
| @@ -1781,6 +1827,14 @@ class Heap { |
| unsigned int last_idle_notification_gc_count_; |
| bool last_idle_notification_gc_count_init_; |
| + bool idle_notification_will_schedule_next_gc_; |
| + int mark_sweeps_since_idle_round_started_; |
| + int ms_count_at_last_idle_notification_; |
| + unsigned int gc_count_at_last_idle_gc_; |
| + unsigned int gc_count_when_last_idle_round_finished_; |
| + |
| + static const int kMaxMarkSweepsInIdleRound = 7; |
| + |
| // Shared state read by the scavenge collector and set by ScavengeObject. |
| PromotionQueue promotion_queue_; |