Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index eb7c7a8cd12525a5e97342b841eceb8f0d1e2551..f6f45304a97530e0eb865489c4b12a33894e4447 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -4585,33 +4585,8 @@ bool Heap::TryFinalizeIdleIncrementalMarking( |
} |
-double Heap::MonotonicallyIncreasingTimeInMs() { |
- return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
- static_cast<double>(base::Time::kMillisecondsPerSecond); |
-} |
- |
- |
-bool Heap::IdleNotification(int idle_time_in_ms) { |
- return IdleNotification( |
- V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + |
- (static_cast<double>(idle_time_in_ms) / |
- static_cast<double>(base::Time::kMillisecondsPerSecond))); |
-} |
- |
- |
-bool Heap::IdleNotification(double deadline_in_seconds) { |
- CHECK(HasBeenSetUp()); // http://crbug.com/425035 |
- double deadline_in_ms = |
- deadline_in_seconds * |
- static_cast<double>(base::Time::kMillisecondsPerSecond); |
- HistogramTimerScope idle_notification_scope( |
- isolate_->counters()->gc_idle_notification()); |
- double start_ms = MonotonicallyIncreasingTimeInMs(); |
- double idle_time_in_ms = deadline_in_ms - start_ms; |
- bool is_long_idle_notification = |
- static_cast<size_t>(idle_time_in_ms) > |
- GCIdleTimeHandler::kMaxFrameRenderingIdleTime; |
- |
+GCIdleTimeHandler::HeapState Heap::ComputeHeapState( |
+ bool is_long_idle_notification) { |
GCIdleTimeHandler::HeapState heap_state; |
heap_state.contexts_disposed = contexts_disposed_; |
heap_state.contexts_disposal_rate = |
@@ -4646,21 +4621,14 @@ bool Heap::IdleNotification(double deadline_in_seconds) { |
heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
static_cast<size_t>( |
tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond()); |
+ return heap_state; |
+} |
- GCIdleTimeAction action = |
- gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
- |
- isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
- static_cast<int>(idle_time_in_ms)); |
- if (is_long_idle_notification) { |
- int committed_memory = static_cast<int>(CommittedMemory() / KB); |
- int used_memory = static_cast<int>(heap_state.size_of_objects / KB); |
- isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
- start_ms, committed_memory); |
- isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
- start_ms, used_memory); |
- } |
+bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, |
+ GCIdleTimeHandler::HeapState heap_state, |
+ double deadline_in_ms, |
+ bool is_long_idle_notification) { |
bool result = false; |
switch (action.type) { |
case DONE: |
@@ -4719,11 +4687,33 @@ bool Heap::IdleNotification(double deadline_in_seconds) { |
new_space_.Shrink(); |
UncommitFromSpace(); |
} |
+ return result; |
+} |
+ |
+void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, |
+ GCIdleTimeHandler::HeapState heap_state, |
+ double start_ms, double deadline_in_ms, |
+ bool is_long_idle_notification) { |
+ double idle_time_in_ms = deadline_in_ms - start_ms; |
double current_time = MonotonicallyIncreasingTimeInMs(); |
last_idle_notification_time_ = current_time; |
double deadline_difference = deadline_in_ms - current_time; |
+ contexts_disposed_ = 0; |
+ |
+ isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample( |
+ idle_time_in_ms); |
+ |
+ if (is_long_idle_notification) { |
Hannes Payer (out of office)
2015/05/20 06:39:32
Diff: this got moved down to the Epilogue.
|
+ int committed_memory = static_cast<int>(CommittedMemory() / KB); |
+ int used_memory = static_cast<int>(heap_state.size_of_objects / KB); |
+ isolate()->counters()->aggregated_memory_heap_committed()->AddSample( |
+ start_ms, committed_memory); |
+ isolate()->counters()->aggregated_memory_heap_used()->AddSample( |
+ start_ms, used_memory); |
+ } |
+ |
if (deadline_difference >= 0) { |
if (action.type != DONE && action.type != DO_NOTHING) { |
isolate()->counters()->gc_idle_time_limit_undershot()->AddSample( |
@@ -4751,8 +4741,47 @@ bool Heap::IdleNotification(double deadline_in_seconds) { |
} |
PrintF("\n"); |
} |
+} |
- contexts_disposed_ = 0; |
+ |
+double Heap::MonotonicallyIncreasingTimeInMs() { |
+ return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
+ static_cast<double>(base::Time::kMillisecondsPerSecond); |
+} |
+ |
+ |
+bool Heap::IdleNotification(int idle_time_in_ms) { |
+ return IdleNotification( |
+ V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + |
+ (static_cast<double>(idle_time_in_ms) / |
+ static_cast<double>(base::Time::kMillisecondsPerSecond))); |
+} |
+ |
+ |
+bool Heap::IdleNotification(double deadline_in_seconds) { |
+ CHECK(HasBeenSetUp()); |
+ double deadline_in_ms = |
+ deadline_in_seconds * |
+ static_cast<double>(base::Time::kMillisecondsPerSecond); |
+ HistogramTimerScope idle_notification_scope( |
+ isolate_->counters()->gc_idle_notification()); |
+ double start_ms = MonotonicallyIncreasingTimeInMs(); |
+ double idle_time_in_ms = deadline_in_ms - start_ms; |
+ bool is_long_idle_notification = |
+ static_cast<size_t>(idle_time_in_ms) > |
+ GCIdleTimeHandler::kMaxFrameRenderingIdleTime; |
+ |
+ GCIdleTimeHandler::HeapState heap_state = |
+ ComputeHeapState(is_long_idle_notification); |
+ |
+ GCIdleTimeAction action = |
+ gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
+ |
+ bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms, |
+ is_long_idle_notification); |
+ |
+ IdleNotificationEpilogue(action, heap_state, start_ms, deadline_in_ms, |
+ is_long_idle_notification); |
return result; |
} |