diff --git a/src/heap/heap.cc b/src/heap/heap.cc index a1b1a51396..9b6d15a471 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -513,22 +513,25 @@ void Heap::AddRetainingPathTarget(Handle object, if (!FLAG_track_retaining_path) { PrintF("Retaining path tracking requires --track-retaining-path\n"); } else { - int index = 0; - Handle array = FixedArrayOfWeakCells::Add( - isolate(), handle(retaining_path_targets(), isolate()), object, &index); + Handle array(retaining_path_targets(), isolate()); + int index = array->length(); + array = WeakArrayList::AddToEnd(isolate(), array, + MaybeObjectHandle::Weak(object)); set_retaining_path_targets(*array); + DCHECK_EQ(array->length(), index + 1); retaining_path_target_option_[index] = option; } } bool Heap::IsRetainingPathTarget(HeapObject* object, RetainingPathOption* option) { - if (!retaining_path_targets()->IsFixedArrayOfWeakCells()) return false; - FixedArrayOfWeakCells* targets = - FixedArrayOfWeakCells::cast(retaining_path_targets()); - int length = targets->Length(); + WeakArrayList* targets = retaining_path_targets(); + int length = targets->length(); + MaybeObject* object_to_check = HeapObjectReference::Weak(object); for (int i = 0; i < length; i++) { - if (targets->Get(i) == object) { + MaybeObject* target = targets->Get(i); + DCHECK(target->IsWeakOrClearedHeapObject()); + if (target == object_to_check) { DCHECK(retaining_path_target_option_.count(i)); *option = retaining_path_target_option_[i]; return true; diff --git a/src/heap/setup-heap-internal.cc b/src/heap/setup-heap-internal.cc index d292d29209..2cd7106e0a 100644 --- a/src/heap/setup-heap-internal.cc +++ b/src/heap/setup-heap-internal.cc @@ -762,7 +762,7 @@ void Heap::CreateInitialObjects() { set_detached_contexts(roots.empty_weak_array_list()); set_retained_maps(roots.empty_weak_array_list()); - set_retaining_path_targets(roots.undefined_value()); + set_retaining_path_targets(roots.empty_weak_array_list()); set_feedback_vectors_for_profiling_tools(roots.undefined_value()); diff --git a/src/roots.h b/src/roots.h index 0fa2fc9d7e..6ab4505879 100644 --- a/src/roots.h +++ b/src/roots.h @@ -237,7 +237,7 @@ namespace internal { V(FixedArray, materialized_objects, MaterializedObjects) \ V(FixedArray, microtask_queue, MicrotaskQueue) \ V(WeakArrayList, detached_contexts, DetachedContexts) \ - V(HeapObject, retaining_path_targets, RetainingPathTargets) \ + V(WeakArrayList, retaining_path_targets, RetainingPathTargets) \ V(WeakArrayList, retained_maps, RetainedMaps) \ /* Indirection lists for isolate-independent builtins */ \ V(FixedArray, builtins_constants_table, BuiltinsConstantsTable) \