Commit cc6bcbce authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[in-place weak refs] Use WeakArrayList in Heap::retaining_path_targets.

BUG=v8:7308

Change-Id: Ie93c398ab5c138a559ee156aeb24a7782280aaa9
Reviewed-on: https://chromium-review.googlesource.com/1148213Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54659}
parent 5f800d25
......@@ -513,22 +513,25 @@ void Heap::AddRetainingPathTarget(Handle<HeapObject> object,
if (!FLAG_track_retaining_path) {
PrintF("Retaining path tracking requires --track-retaining-path\n");
} else {
int index = 0;
Handle<FixedArrayOfWeakCells> array = FixedArrayOfWeakCells::Add(
isolate(), handle(retaining_path_targets(), isolate()), object, &index);
Handle<WeakArrayList> 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;
......
......@@ -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());
......
......@@ -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) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment