From 39c83bfa089ce9f4006ba0663bd1518bf2ba5c15 Mon Sep 17 00:00:00 2001 From: "ulan@chromium.org" Date: Fri, 22 Aug 2014 13:02:11 +0000 Subject: [PATCH] Remove dependency on GCTrace from GCIdleTimeHandler. This makes testing GCIdleTimeHandler easier. BUG= R=hpayer@chromium.org Review URL: https://codereview.chromium.org/496253002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23314 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap/gc-idle-time-handler.cc | 15 ++++++--------- src/heap/gc-idle-time-handler.h | 5 +++-- src/heap/heap.cc | 6 +++++- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/heap/gc-idle-time-handler.cc b/src/heap/gc-idle-time-handler.cc index 094723a..1c4476d 100644 --- a/src/heap/gc-idle-time-handler.cc +++ b/src/heap/gc-idle-time-handler.cc @@ -46,8 +46,7 @@ size_t GCIdleTimeHandler::EstimateMarkCompactTime( GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, - HeapState heap_state, - GCTracer* gc_tracer) { + HeapState heap_state) { if (IsIdleRoundFinished()) { if (EnoughGarbageSinceLastIdleRound() || heap_state.contexts_disposed > 0) { StartIdleRound(); @@ -56,10 +55,9 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, } } if (heap_state.incremental_marking_stopped) { - size_t speed = - static_cast(gc_tracer->MarkCompactSpeedInBytesPerMillisecond()); - if (idle_time_in_ms >= - EstimateMarkCompactTime(heap_state.size_of_objects, speed)) { + if (idle_time_in_ms >= EstimateMarkCompactTime( + heap_state.size_of_objects, + heap_state.mark_compact_speed_in_bytes_per_ms)) { // If there are no more than two GCs left in this idle round and we are // allowed to do a full GC, then make those GCs full in order to compact // the code space. @@ -82,9 +80,8 @@ GCIdleTimeAction GCIdleTimeHandler::Compute(size_t idle_time_in_ms, return GCIdleTimeAction::FinalizeSweeping(); } - intptr_t speed = gc_tracer->IncrementalMarkingSpeedInBytesPerMillisecond(); - size_t step_size = - static_cast(EstimateMarkingStepSize(idle_time_in_ms, speed)); + size_t step_size = EstimateMarkingStepSize( + idle_time_in_ms, heap_state.incremental_marking_speed_in_bytes_per_ms); return GCIdleTimeAction::IncrementalMarking(step_size); } } diff --git a/src/heap/gc-idle-time-handler.h b/src/heap/gc-idle-time-handler.h index 6c1e4fb..4d73814 100644 --- a/src/heap/gc-idle-time-handler.h +++ b/src/heap/gc-idle-time-handler.h @@ -95,14 +95,15 @@ class GCIdleTimeHandler { bool incremental_marking_stopped; bool can_start_incremental_marking; bool sweeping_in_progress; + size_t mark_compact_speed_in_bytes_per_ms; + size_t incremental_marking_speed_in_bytes_per_ms; }; GCIdleTimeHandler() : mark_compacts_since_idle_round_started_(0), scavenges_since_last_idle_round_(0) {} - GCIdleTimeAction Compute(size_t idle_time_in_ms, HeapState heap_state, - GCTracer* gc_tracer); + GCIdleTimeAction Compute(size_t idle_time_in_ms, HeapState heap_state); void NotifyIdleMarkCompact() { if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { diff --git a/src/heap/heap.cc b/src/heap/heap.cc index c757d60..119d150 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -4298,9 +4298,13 @@ bool Heap::IdleNotification(int idle_time_in_ms) { heap_state.can_start_incremental_marking = true; heap_state.sweeping_in_progress = mark_compact_collector()->sweeping_in_progress(); + heap_state.mark_compact_speed_in_bytes_per_ms = + static_cast(tracer()->MarkCompactSpeedInBytesPerMillisecond()); + heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast( + tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); GCIdleTimeAction action = - gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state, tracer()); + gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); contexts_disposed_ = 0; bool result = false; -- 2.7.4