From: mlippautz Date: Mon, 3 Aug 2015 18:25:00 +0000 (-0700) Subject: GC: Refactor incremental marking steps w/ deadline into a separate call X-Git-Tag: upstream/4.7.83~1054 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=869ab06ea5165ce0dc01396150a110478f8a3e42;p=platform%2Fupstream%2Fv8.git GC: Refactor incremental marking steps w/ deadline into a separate call BUG= Review URL: https://codereview.chromium.org/1270873002 Cr-Commit-Position: refs/heads/master@{#29986} --- diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 3a0fd2c..8be12f2 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -4787,6 +4787,24 @@ GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { } +double Heap::AdvanceIncrementalMarking( + intptr_t step_size_in_bytes, double deadline_in_ms, + IncrementalMarking::ForceCompletionAction completion) { + DCHECK(!incremental_marking()->IsStopped()); + double remaining_time_in_ms = 0.0; + do { + incremental_marking()->Step(step_size_in_bytes, + IncrementalMarking::NO_GC_VIA_STACK_GUARD, + IncrementalMarking::FORCE_MARKING, completion); + remaining_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); + } while (remaining_time_in_ms >= + 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && + !incremental_marking()->IsComplete() && + !mark_compact_collector_.marking_deque()->IsEmpty()); + return remaining_time_in_ms; +} + + bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, GCIdleTimeHandler::HeapState heap_state, double deadline_in_ms) { @@ -4796,19 +4814,9 @@ bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, result = true; break; case DO_INCREMENTAL_MARKING: { - DCHECK(!incremental_marking()->IsStopped()); - double remaining_idle_time_in_ms = 0.0; - do { - incremental_marking()->Step( - action.parameter, IncrementalMarking::NO_GC_VIA_STACK_GUARD, - IncrementalMarking::FORCE_MARKING, - IncrementalMarking::DO_NOT_FORCE_COMPLETION); - remaining_idle_time_in_ms = - deadline_in_ms - MonotonicallyIncreasingTimeInMs(); - } while (remaining_idle_time_in_ms >= - 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && - !incremental_marking()->IsComplete() && - !mark_compact_collector_.marking_deque()->IsEmpty()); + const double remaining_idle_time_in_ms = AdvanceIncrementalMarking( + action.parameter, deadline_in_ms, + IncrementalMarking::DO_NOT_FORCE_COMPLETION); if (remaining_idle_time_in_ms > 0.0) { action.additional_work = TryFinalizeIdleIncrementalMarking( remaining_idle_time_in_ms, heap_state.size_of_objects, diff --git a/src/heap/heap.h b/src/heap/heap.h index f8955ac..398cffe 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -2228,6 +2228,10 @@ class Heap { GCIdleTimeHandler::HeapState ComputeHeapState(); + double AdvanceIncrementalMarking( + intptr_t step_size_in_bytes, double deadline_in_ms, + IncrementalMarking::ForceCompletionAction completion); + bool PerformIdleTimeAction(GCIdleTimeAction action, GCIdleTimeHandler::HeapState heap_state, double deadline_in_ms);