diff --git a/src/handles/global-handles.cc b/src/handles/global-handles.cc index fcec0ca761..c0115e8f85 100644 --- a/src/handles/global-handles.cc +++ b/src/handles/global-handles.cc @@ -1232,7 +1232,6 @@ void GlobalHandles::IterateYoungStrongAndDependentRoots(RootVisitor* v) { v->VisitRootPointer(Root::kGlobalHandles, nullptr, node->location()); } } - on_stack_nodes_->Iterate(v); } void GlobalHandles::MarkYoungWeakUnmodifiedObjectsPending( @@ -1517,6 +1516,9 @@ void GlobalHandles::IterateStrongRoots(RootVisitor* v) { node->location()); } } +} + +void GlobalHandles::IterateStrongStackRoots(RootVisitor* v) { on_stack_nodes_->Iterate(v); } diff --git a/src/handles/global-handles.h b/src/handles/global-handles.h index e2e733d8f2..320c3b7662 100644 --- a/src/handles/global-handles.h +++ b/src/handles/global-handles.h @@ -121,6 +121,7 @@ class V8_EXPORT_PRIVATE GlobalHandles final { GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags); void IterateStrongRoots(RootVisitor* v); + void IterateStrongStackRoots(RootVisitor* v); void IterateWeakRoots(RootVisitor* v); void IterateAllRoots(RootVisitor* v); void IterateAllYoungRoots(RootVisitor* v); diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 84c4791d9b..4de5cdc8f7 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -4381,6 +4381,7 @@ void Heap::IterateStrongRoots(RootVisitor* v, VisitMode mode) { v->Synchronize(VisitorSynchronization::kBootstrapper); if (mode != VISIT_ONLY_STRONG_IGNORE_STACK) { isolate_->Iterate(v); + isolate_->global_handles()->IterateStrongStackRoots(v); v->Synchronize(VisitorSynchronization::kTop); } Relocatable::Iterate(isolate_, v); diff --git a/src/heap/incremental-marking-job.cc b/src/heap/incremental-marking-job.cc index 1f924ff139..1e21d4b926 100644 --- a/src/heap/incremental-marking-job.cc +++ b/src/heap/incremental-marking-job.cc @@ -18,8 +18,7 @@ namespace internal { class IncrementalMarkingJob::Task : public CancelableTask { public: - static StepResult Step(Heap* heap, - EmbedderHeapTracer::EmbedderStackState stack_state); + static StepResult Step(Heap* heap); Task(Isolate* isolate, IncrementalMarkingJob* job, EmbedderHeapTracer::EmbedderStackState stack_state, TaskType task_type) @@ -80,20 +79,15 @@ void IncrementalMarkingJob::ScheduleTask(Heap* heap, TaskType task_type) { } } -StepResult IncrementalMarkingJob::Task::Step( - Heap* heap, EmbedderHeapTracer::EmbedderStackState stack_state) { +StepResult IncrementalMarkingJob::Task::Step(Heap* heap) { const int kIncrementalMarkingDelayMs = 1; double deadline = heap->MonotonicallyIncreasingTimeInMs() + kIncrementalMarkingDelayMs; StepResult result = heap->incremental_marking()->AdvanceWithDeadline( deadline, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD, i::StepOrigin::kTask); - { - EmbedderStackStateScope scope(heap->local_embedder_heap_tracer(), - stack_state); - heap->FinalizeIncrementalMarkingIfComplete( - GarbageCollectionReason::kFinalizeMarkingViaTask); - } + heap->FinalizeIncrementalMarkingIfComplete( + GarbageCollectionReason::kFinalizeMarkingViaTask); return result; } @@ -102,6 +96,8 @@ void IncrementalMarkingJob::Task::RunInternal() { TRACE_EVENT_CALL_STATS_SCOPED(isolate(), "v8", "V8.Task"); Heap* heap = isolate()->heap(); + EmbedderStackStateScope scope(heap->local_embedder_heap_tracer(), + stack_state_); IncrementalMarking* incremental_marking = heap->incremental_marking(); if (incremental_marking->IsStopped()) { if (heap->IncrementalMarkingLimitReached() != @@ -117,7 +113,7 @@ void IncrementalMarkingJob::Task::RunInternal() { job_->SetTaskPending(task_type_, false); if (!incremental_marking->IsStopped()) { - StepResult step_result = Step(heap, stack_state_); + StepResult step_result = Step(heap); if (!incremental_marking->IsStopped()) { job_->ScheduleTask(heap, step_result == StepResult::kNoImmediateWork ? TaskType::kDelayed