From a44b20abe343674637b73e2e9a49ef834e550684 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Tue, 11 Feb 2020 20:23:18 -0800 Subject: [PATCH] [weakrefs] Rename JSFinalizationGroup's next field to next_dirty R=ulan@chromium.org Bug: v8:8179 Change-Id: I9626bd070453ce1b7d4b91cf78b9f75b74dfddbe Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2051605 Commit-Queue: Shu-yu Guo Reviewed-by: Ulan Degenbaev Cr-Commit-Position: refs/heads/master@{#66252} --- src/diagnostics/objects-debug.cc | 3 ++- src/heap/heap.cc | 23 ++++++++++++---------- src/heap/objects-visiting.cc | 6 +++--- src/objects/js-weak-refs-inl.h | 2 +- src/objects/js-weak-refs.h | 3 +-- src/objects/js-weak-refs.tq | 2 +- src/objects/objects-body-descriptors-inl.h | 10 +++++----- 7 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/diagnostics/objects-debug.cc b/src/diagnostics/objects-debug.cc index 4def6098b6..3bf9240eb6 100644 --- a/src/diagnostics/objects-debug.cc +++ b/src/diagnostics/objects-debug.cc @@ -1083,7 +1083,8 @@ void JSFinalizationGroup::JSFinalizationGroupVerify(Isolate* isolate) { if (cleared_cells().IsWeakCell()) { CHECK(WeakCell::cast(cleared_cells()).prev().IsUndefined(isolate)); } - CHECK(next().IsUndefined(isolate) || next().IsJSFinalizationGroup()); + CHECK(next_dirty().IsUndefined(isolate) || + next_dirty().IsJSFinalizationGroup()); } void JSFinalizationGroupCleanupIterator:: diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 97d5ef68ef..40bf8f15b8 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -6075,13 +6075,13 @@ void Heap::AddDirtyJSFinalizationGroup( gc_notify_updated_slot) { DCHECK(!HasDirtyJSFinalizationGroups() || dirty_js_finalization_groups_list().IsJSFinalizationGroup()); - DCHECK(finalization_group.next().IsUndefined(isolate())); + DCHECK(finalization_group.next_dirty().IsUndefined(isolate())); DCHECK(!finalization_group.scheduled_for_cleanup()); finalization_group.set_scheduled_for_cleanup(true); - finalization_group.set_next(dirty_js_finalization_groups_list()); + finalization_group.set_next_dirty(dirty_js_finalization_groups_list()); gc_notify_updated_slot( finalization_group, - finalization_group.RawField(JSFinalizationGroup::kNextOffset), + finalization_group.RawField(JSFinalizationGroup::kNextDirtyOffset), dirty_js_finalization_groups_list()); set_dirty_js_finalization_groups_list(finalization_group); // dirty_js_finalization_groups_list is rescanned by ProcessWeakListRoots. @@ -6092,8 +6092,9 @@ MaybeHandle Heap::TakeOneDirtyJSFinalizationGroup() { Handle finalization_group( JSFinalizationGroup::cast(dirty_js_finalization_groups_list()), isolate()); - set_dirty_js_finalization_groups_list(finalization_group->next()); - finalization_group->set_next(ReadOnlyRoots(isolate()).undefined_value()); + set_dirty_js_finalization_groups_list(finalization_group->next_dirty()); + finalization_group->set_next_dirty( + ReadOnlyRoots(isolate()).undefined_value()); return finalization_group; } return {}; @@ -6112,16 +6113,18 @@ void Heap::RemoveDirtyFinalizationGroupsOnContext(NativeContext context) { JSFinalizationGroup finalization_group = JSFinalizationGroup::cast(current); if (finalization_group.native_context() == context) { if (prev.IsUndefined(isolate)) { - set_dirty_js_finalization_groups_list(finalization_group.next()); + set_dirty_js_finalization_groups_list(finalization_group.next_dirty()); } else { - JSFinalizationGroup::cast(prev).set_next(finalization_group.next()); + JSFinalizationGroup::cast(prev).set_next_dirty( + finalization_group.next_dirty()); } finalization_group.set_scheduled_for_cleanup(false); - current = finalization_group.next(); - finalization_group.set_next(ReadOnlyRoots(isolate).undefined_value()); + current = finalization_group.next_dirty(); + finalization_group.set_next_dirty( + ReadOnlyRoots(isolate).undefined_value()); } else { prev = current; - current = finalization_group.next(); + current = finalization_group.next_dirty(); } } } diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc index 2aa675c633..d6249e194b 100644 --- a/src/heap/objects-visiting.cc +++ b/src/heap/objects-visiting.cc @@ -188,14 +188,14 @@ struct WeakListVisitor { template <> struct WeakListVisitor { static void SetWeakNext(JSFinalizationGroup obj, Object next) { - obj.set_next(next, UPDATE_WEAK_WRITE_BARRIER); + obj.set_next_dirty(next, UPDATE_WEAK_WRITE_BARRIER); } - static Object WeakNext(JSFinalizationGroup obj) { return obj.next(); } + static Object WeakNext(JSFinalizationGroup obj) { return obj.next_dirty(); } static HeapObject WeakNextHolder(JSFinalizationGroup obj) { return obj; } - static int WeakNextOffset() { return JSFinalizationGroup::kNextOffset; } + static int WeakNextOffset() { return JSFinalizationGroup::kNextDirtyOffset; } static void VisitLiveObject(Heap*, JSFinalizationGroup, WeakObjectRetainer*) { } diff --git a/src/objects/js-weak-refs-inl.h b/src/objects/js-weak-refs-inl.h index 477b88cdd1..4ab313ef78 100644 --- a/src/objects/js-weak-refs-inl.h +++ b/src/objects/js-weak-refs-inl.h @@ -29,7 +29,7 @@ ACCESSORS(JSFinalizationGroup, active_cells, HeapObject, kActiveCellsOffset) ACCESSORS(JSFinalizationGroup, cleared_cells, HeapObject, kClearedCellsOffset) ACCESSORS(JSFinalizationGroup, key_map, Object, kKeyMapOffset) SMI_ACCESSORS(JSFinalizationGroup, flags, kFlagsOffset) -ACCESSORS(JSFinalizationGroup, next, Object, kNextOffset) +ACCESSORS(JSFinalizationGroup, next_dirty, Object, kNextDirtyOffset) CAST_ACCESSOR(JSFinalizationGroup) void JSFinalizationGroup::Register( diff --git a/src/objects/js-weak-refs.h b/src/objects/js-weak-refs.h index 310b5e7295..fb9d4baca8 100644 --- a/src/objects/js-weak-refs.h +++ b/src/objects/js-weak-refs.h @@ -31,8 +31,7 @@ class JSFinalizationGroup : public JSObject { DECL_ACCESSORS(cleared_cells, HeapObject) DECL_ACCESSORS(key_map, Object) - // For storing a list of JSFinalizationGroup objects in NativeContext. - DECL_ACCESSORS(next, Object) + DECL_ACCESSORS(next_dirty, Object) DECL_INT_ACCESSORS(flags) diff --git a/src/objects/js-weak-refs.tq b/src/objects/js-weak-refs.tq index 970f490233..53d1ed45bb 100644 --- a/src/objects/js-weak-refs.tq +++ b/src/objects/js-weak-refs.tq @@ -10,7 +10,7 @@ extern class JSFinalizationGroup extends JSObject { key_map: Object; // For the linked list of FinalizationGroups that need cleanup. This link // is weak. - next: Undefined|JSFinalizationGroup; + next_dirty: Undefined|JSFinalizationGroup; flags: Smi; } diff --git a/src/objects/objects-body-descriptors-inl.h b/src/objects/objects-body-descriptors-inl.h index f2dd3c91ee..8f76834bd2 100644 --- a/src/objects/objects-body-descriptors-inl.h +++ b/src/objects/objects-body-descriptors-inl.h @@ -257,11 +257,11 @@ class JSFinalizationGroup::BodyDescriptor final : public BodyDescriptorBase { template static inline void IterateBody(Map map, HeapObject obj, int object_size, ObjectVisitor* v) { - IteratePointers(obj, JSObject::BodyDescriptor::kStartOffset, kNextOffset, - v); - IterateCustomWeakPointer(obj, kNextOffset, v); - IterateJSObjectBodyImpl(map, obj, kNextOffset + kTaggedSize, object_size, - v); + IteratePointers(obj, JSObject::BodyDescriptor::kStartOffset, + kNextDirtyOffset, v); + IterateCustomWeakPointer(obj, kNextDirtyOffset, v); + IterateJSObjectBodyImpl(map, obj, kNextDirtyOffset + kTaggedSize, + object_size, v); } static inline int SizeOf(Map map, HeapObject object) {