From 8d9381129eddc28b5e801446d230f1ba1251a37d Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Thu, 23 Oct 2014 15:16:27 +0000 Subject: [PATCH] Shrink new space in idle notification. BUG=chromium:424423 LOG=Y R=jochen@chromium.org Review URL: https://codereview.chromium.org/662543008 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24851 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap/heap.cc | 47 ++++++++++++++++++++++++++++------------------- src/heap/heap.h | 2 ++ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 2349f2fa4f..38e4971f4a 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -1570,6 +1570,8 @@ void Heap::Scavenge() { LOG(isolate_, ResourceEvent("scavenge", "end")); gc_state_ = NOT_IN_GC; + + gc_idle_time_handler_.NotifyScavenge(); } @@ -4301,6 +4303,23 @@ void Heap::MakeHeapIterable() { } +void Heap::IdleMarkCompact(const char* message) { + bool uncommit = false; + if (gc_count_at_last_idle_gc_ == gc_count_) { + // No GC since the last full GC, the mutator is probably not active. + isolate_->compilation_cache()->Clear(); + uncommit = true; + } + CollectAllGarbage(kReduceMemoryFootprintMask, message); + gc_idle_time_handler_.NotifyIdleMarkCompact(); + gc_count_at_last_idle_gc_ = gc_count_; + if (uncommit) { + new_space_.Shrink(); + UncommitFromSpace(); + } +} + + void Heap::TryFinalizeIdleIncrementalMarking( size_t idle_time_in_ms, size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms) { @@ -4309,20 +4328,7 @@ void Heap::TryFinalizeIdleIncrementalMarking( gc_idle_time_handler_.ShouldDoMarkCompact( idle_time_in_ms, size_of_objects, mark_compact_speed_in_bytes_per_ms))) { - bool uncommit = false; - if (gc_count_at_last_idle_gc_ == gc_count_) { - // No GC since the last full GC, the mutator is probably not active. - isolate_->compilation_cache()->Clear(); - uncommit = true; - } - CollectAllGarbage(kReduceMemoryFootprintMask, - "idle notification: finalize incremental"); - gc_idle_time_handler_.NotifyIdleMarkCompact(); - gc_count_at_last_idle_gc_ = gc_count_; - if (uncommit) { - new_space_.Shrink(); - UncommitFromSpace(); - } + IdleMarkCompact("idle notification: finalize incremental"); } } @@ -4392,11 +4398,14 @@ bool Heap::IdleNotification(int idle_time_in_ms) { } case DO_FULL_GC: { HistogramTimerScope scope(isolate_->counters()->gc_context()); - const char* message = contexts_disposed_ - ? "idle notification: contexts disposed" - : "idle notification: finalize idle round"; - CollectAllGarbage(kReduceMemoryFootprintMask, message); - gc_idle_time_handler_.NotifyIdleMarkCompact(); + if (contexts_disposed_) { + CollectAllGarbage(kReduceMemoryFootprintMask, + "idle notification: contexts disposed"); + gc_idle_time_handler_.NotifyIdleMarkCompact(); + gc_count_at_last_idle_gc_ = gc_count_; + } else { + IdleMarkCompact("idle notification: finalize idle round"); + } break; } case DO_SCAVENGE: diff --git a/src/heap/heap.h b/src/heap/heap.h index c0848c926f..f3830dd18b 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -1975,6 +1975,8 @@ class Heap { void SelectScavengingVisitorsTable(); + void IdleMarkCompact(const char* message); + void TryFinalizeIdleIncrementalMarking( size_t idle_time_in_ms, size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms);