diff --git a/src/heap/gc-idle-time-handler.h b/src/heap/gc-idle-time-handler.h index 39dea7e1ff..709aa913da 100644 --- a/src/heap/gc-idle-time-handler.h +++ b/src/heap/gc-idle-time-handler.h @@ -113,6 +113,10 @@ class GCIdleTimeHandler { // Incremental marking step time. static const size_t kIncrementalMarkingStepTimeInMs = 1; + // Minimum incremental marking step time. + static const size_t kMinIncrementalMarkingStepTimeInMs = + kIncrementalMarkingStepTimeInMs + 1; + static const size_t kMinTimeForOverApproximatingWeakClosureInMs; // Number of times we will return a Nothing action in the current mode diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index 024e110766..7662a334b3 100644 --- a/src/heap/incremental-marking.cc +++ b/src/heap/incremental-marking.cc @@ -1024,20 +1024,17 @@ double IncrementalMarking::AdvanceIncrementalMarking( heap() ->tracer() ->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); - double remaining_time_in_ms = 0.0; - intptr_t bytes_processed = 0; - - do { - bytes_processed = + double remaining_time_in_ms = + deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs(); + while (remaining_time_in_ms >= + GCIdleTimeHandler::kMinIncrementalMarkingStepTimeInMs) { + intptr_t bytes_processed = Step(step_size_in_bytes, step_actions.completion_action, step_actions.force_marking, step_actions.force_completion); remaining_time_in_ms = deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs(); - } while (bytes_processed > 0 && - remaining_time_in_ms >= - 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && - !IsComplete() && - !heap()->mark_compact_collector()->marking_deque()->IsEmpty()); + if (bytes_processed == 0) break; + } return remaining_time_in_ms; }