diff --git a/src/global-handles.cc b/src/global-handles.cc index 340ede7e42..8e1da8f4ca 100644 --- a/src/global-handles.cc +++ b/src/global-handles.cc @@ -715,22 +715,6 @@ void GlobalHandles::IterateNewSpaceStrongAndDependentRoots(RootVisitor* v) { } } -void GlobalHandles::IterateNewSpaceStrongAndDependentRootsAndIdentifyUnmodified( - RootVisitor* v, size_t start, size_t end) { - for (size_t i = start; i < end; ++i) { - Node* node = new_space_nodes_[i]; - if (node->IsWeak() && !JSObject::IsUnmodifiedApiObject(node->location())) { - node->set_active(true); - } - if (node->IsStrongRetainer() || - (node->IsWeakRetainer() && !node->is_independent() && - node->is_active())) { - v->VisitRootPointer(Root::kGlobalHandles, node->label(), - node->location()); - } - } -} - void GlobalHandles::IdentifyWeakUnmodifiedObjects( WeakSlotCallback is_unmodified) { for (Node* node : new_space_nodes_) { @@ -1007,18 +991,6 @@ void GlobalHandles::IterateAllNewSpaceRoots(RootVisitor* v) { } } -DISABLE_CFI_PERF -void GlobalHandles::IterateNewSpaceRoots(RootVisitor* v, size_t start, - size_t end) { - for (size_t i = start; i < end; ++i) { - Node* node = new_space_nodes_[i]; - if (node->IsRetainer()) { - v->VisitRootPointer(Root::kGlobalHandles, node->label(), - node->location()); - } - } -} - DISABLE_CFI_PERF void GlobalHandles::ApplyPersistentHandleVisitor( v8::PersistentHandleVisitor* visitor, GlobalHandles::Node* node) { diff --git a/src/global-handles.h b/src/global-handles.h index 8d2f31c349..d12e0c10fd 100644 --- a/src/global-handles.h +++ b/src/global-handles.h @@ -102,7 +102,6 @@ class GlobalHandles final { void IterateAllRoots(RootVisitor* v); void IterateAllNewSpaceRoots(RootVisitor* v); - void IterateNewSpaceRoots(RootVisitor* v, size_t start, size_t end); // Iterates over all handles that have embedder-assigned class ID. void IterateAllRootsWithClassIds(v8::PersistentHandleVisitor* v); @@ -132,11 +131,6 @@ class GlobalHandles final { // Iterates over strong and dependent handles. See the note above. void IterateNewSpaceStrongAndDependentRoots(RootVisitor* v); - // Iterates over strong and dependent handles. See the note above. - // Also marks unmodified nodes in the same iteration. - void IterateNewSpaceStrongAndDependentRootsAndIdentifyUnmodified( - RootVisitor* v, size_t start, size_t end); - // Marks weak unmodified handles satisfying |is_dead| as pending. void MarkNewSpaceWeakUnmodifiedObjectsPending( WeakSlotCallbackWithHeap is_dead); @@ -155,7 +149,6 @@ class GlobalHandles final { // Number of global handles. size_t handles_count() const { return handles_count_; } - size_t new_space_handles_count() const { return new_space_nodes_.size(); } size_t GetAndResetGlobalHandleResetCount() { size_t old = number_of_phantom_handle_resets_; diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 3853ce68c7..ea3e55da56 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -3882,13 +3882,11 @@ void Heap::IterateStrongRoots(RootVisitor* v, VisitMode mode) { isolate_->global_handles()->IterateStrongRoots(v); break; case VISIT_ALL_IN_SCAVENGE: + case VISIT_ALL_IN_MINOR_MC_MARK: isolate_->global_handles()->IterateNewSpaceStrongAndDependentRoots(v); break; - case VISIT_ALL_IN_MINOR_MC_MARK: - // Global handles are processed manually by the minor MC. - break; case VISIT_ALL_IN_MINOR_MC_UPDATE: - // Global handles are processed manually by the minor MC. + isolate_->global_handles()->IterateAllNewSpaceRoots(v); break; case VISIT_ALL_IN_SWEEP_NEWSPACE: case VISIT_ALL: diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 775469a2ad..b998626cc2 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -3358,26 +3358,6 @@ UpdatingItem* MarkCompactCollector::CreateRememberedSetUpdatingItem( heap(), non_atomic_marking_state(), chunk, updating_mode); } -class GlobalHandlesUpdatingItem : public UpdatingItem { - public: - GlobalHandlesUpdatingItem(GlobalHandles* global_handles, size_t start, - size_t end) - : global_handles_(global_handles), start_(start), end_(end) {} - ~GlobalHandlesUpdatingItem() override = default; - - void Process() override { - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), - "GlobalHandlesUpdatingItem::Process"); - PointersUpdatingVisitor updating_visitor; - global_handles_->IterateNewSpaceRoots(&updating_visitor, start_, end_); - } - - private: - GlobalHandles* global_handles_; - size_t start_; - size_t end_; -}; - // Update array buffers on a page that has been evacuated by copying objects. // Target page exclusivity in old space is guaranteed by the fact that // evacuation tasks either (a) retrieved a fresh page, or (b) retrieved all @@ -3872,19 +3852,6 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier { #endif // VERIFY_HEAP -template -void SeedGlobalHandles(GlobalHandles* global_handles, ItemParallelJob* job) { - // Create batches of global handles. - const size_t kGlobalHandlesBufferSize = 1000; - const size_t new_space_nodes = global_handles->new_space_handles_count(); - for (size_t start = 0; start < new_space_nodes; - start += kGlobalHandlesBufferSize) { - size_t end = start + kGlobalHandlesBufferSize; - if (end > new_space_nodes) end = new_space_nodes; - job->AddItem(new ParallelItem(global_handles, start, end)); - } -} - bool IsUnmarkedObjectForYoungGeneration(Heap* heap, FullObjectSlot p) { DCHECK_IMPLIES(Heap::InNewSpace(*p), Heap::InToSpace(*p)); return Heap::InNewSpace(*p) && !heap->minor_mark_compact_collector() @@ -4071,8 +4038,6 @@ void MinorMarkCompactCollector::UpdatePointersAfterEvacuation() { CollectNewSpaceArrayBufferTrackerItems(&updating_job); // Create batches of global handles. - SeedGlobalHandles(isolate()->global_handles(), - &updating_job); const int to_space_tasks = CollectToSpaceUpdatingItems(&updating_job); int remembered_set_pages = 0; remembered_set_pages += CollectRememberedSetUpdatingItems( @@ -4369,7 +4334,6 @@ UpdatingItem* MinorMarkCompactCollector::CreateRememberedSetUpdatingItem( } class MarkingItem; -class GlobalHandlesMarkingItem; class PageMarkingItem; class RootMarkingItem; class YoungGenerationMarkingTask; @@ -4522,51 +4486,6 @@ class PageMarkingItem : public MarkingItem { int slots_; }; -class GlobalHandlesMarkingItem : public MarkingItem { - public: - GlobalHandlesMarkingItem(GlobalHandles* global_handles, size_t start, - size_t end) - : global_handles_(global_handles), start_(start), end_(end) {} - ~GlobalHandlesMarkingItem() override = default; - - void Process(YoungGenerationMarkingTask* task) override { - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.gc"), - "GlobalHandlesMarkingItem::Process"); - GlobalHandlesRootMarkingVisitor visitor(task); - global_handles_ - ->IterateNewSpaceStrongAndDependentRootsAndIdentifyUnmodified( - &visitor, start_, end_); - } - - private: - class GlobalHandlesRootMarkingVisitor : public RootVisitor { - public: - explicit GlobalHandlesRootMarkingVisitor(YoungGenerationMarkingTask* task) - : task_(task) {} - - void VisitRootPointer(Root root, const char* description, - FullObjectSlot p) override { - DCHECK_EQ(Root::kGlobalHandles, root); - task_->MarkObject(*p); - } - - void VisitRootPointers(Root root, const char* description, - FullObjectSlot start, FullObjectSlot end) override { - DCHECK_EQ(Root::kGlobalHandles, root); - for (FullObjectSlot p = start; p < end; ++p) { - task_->MarkObject(*p); - } - } - - private: - YoungGenerationMarkingTask* task_; - }; - - GlobalHandles* global_handles_; - size_t start_; - size_t end_; -}; - void MinorMarkCompactCollector::MarkRootSetInParallel( RootMarkingVisitor* root_visitor) { std::atomic slots; @@ -4577,10 +4496,9 @@ void MinorMarkCompactCollector::MarkRootSetInParallel( // Seed the root set (roots + old->new set). { TRACE_GC(heap()->tracer(), GCTracer::Scope::MINOR_MC_MARK_SEED); + isolate()->global_handles()->IdentifyWeakUnmodifiedObjects( + &JSObject::IsUnmodifiedApiObject); heap()->IterateRoots(root_visitor, VISIT_ALL_IN_MINOR_MC_MARK); - // Create batches of global handles. - SeedGlobalHandles(isolate()->global_handles(), - &job); // Create items for each page. RememberedSet::IterateMemoryChunks( heap(), [&job, &slots](MemoryChunk* chunk) {