Index: src/heap/incremental-marking.cc |
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc |
index 54589c485793906dbad8ba40e6bccf50d9316502..c6e81c67eb6109d55192de87364081efbbdda70b 100644 |
--- a/src/heap/incremental-marking.cc |
+++ b/src/heap/incremental-marking.cc |
@@ -1034,28 +1034,8 @@ |
kStepSizeInMs, |
heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); |
- const bool incremental_wrapper_tracing = |
- state_ == MARKING && FLAG_incremental_marking_wrappers && |
- heap_->local_embedder_heap_tracer()->InUse(); |
- bool trace_wrappers_toggle = true; |
do { |
- if (incremental_wrapper_tracing && trace_wrappers_toggle) { |
- TRACE_GC(heap()->tracer(), |
- GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING); |
- const double wrapper_deadline = |
- heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs; |
- if (!heap_->local_embedder_heap_tracer() |
- ->ShouldFinalizeIncrementalMarking()) { |
- heap_->local_embedder_heap_tracer()->Trace( |
- wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions( |
- EmbedderHeapTracer::ForceCompletionAction:: |
- DO_NOT_FORCE_COMPLETION)); |
- } |
- } else { |
- Step(step_size_in_bytes, completion_action, force_completion, |
- step_origin); |
- } |
- trace_wrappers_toggle = !trace_wrappers_toggle; |
+ Step(step_size_in_bytes, completion_action, force_completion, step_origin); |
remaining_time_in_ms = |
deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs(); |
} while (remaining_time_in_ms >= kStepSizeInMs && !IsComplete() && |
@@ -1154,26 +1134,42 @@ |
size_t bytes_processed = 0; |
if (state_ == MARKING) { |
- bytes_processed = ProcessMarkingDeque(bytes_to_process); |
- if (step_origin == StepOrigin::kTask) { |
- bytes_marked_ahead_of_schedule_ += bytes_processed; |
- } |
- |
- if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) { |
- if (heap_->local_embedder_heap_tracer() |
- ->ShouldFinalizeIncrementalMarking()) { |
- if (completion == FORCE_COMPLETION || |
- IsIdleMarkingDelayCounterLimitReached()) { |
- if (!finalize_marking_completed_) { |
- FinalizeMarking(action); |
- } else { |
- MarkingComplete(action); |
- } |
+ const bool incremental_wrapper_tracing = |
+ FLAG_incremental_marking_wrappers && |
+ heap_->local_embedder_heap_tracer()->InUse(); |
+ const bool process_wrappers = |
+ incremental_wrapper_tracing && |
+ (heap_->local_embedder_heap_tracer() |
+ ->RequiresImmediateWrapperProcessing() || |
+ heap_->mark_compact_collector()->marking_deque()->IsEmpty()); |
+ bool wrapper_work_left = incremental_wrapper_tracing; |
+ if (!process_wrappers) { |
+ bytes_processed = ProcessMarkingDeque(bytes_to_process); |
+ if (step_origin == StepOrigin::kTask) { |
+ bytes_marked_ahead_of_schedule_ += bytes_processed; |
+ } |
+ } else { |
+ const double wrapper_deadline = |
+ heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs; |
+ TRACE_GC(heap()->tracer(), |
+ GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING); |
+ wrapper_work_left = heap_->local_embedder_heap_tracer()->Trace( |
+ wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions( |
+ EmbedderHeapTracer::ForceCompletionAction:: |
+ DO_NOT_FORCE_COMPLETION)); |
+ } |
+ |
+ if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && |
+ !wrapper_work_left) { |
+ if (completion == FORCE_COMPLETION || |
+ IsIdleMarkingDelayCounterLimitReached()) { |
+ if (!finalize_marking_completed_) { |
+ FinalizeMarking(action); |
} else { |
- IncrementIdleMarkingDelayCounter(); |
+ MarkingComplete(action); |
} |
} else { |
- heap_->local_embedder_heap_tracer()->NotifyV8MarkingDequeWasEmpty(); |
+ IncrementIdleMarkingDelayCounter(); |
} |
} |
} |