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

[cleanup] Refactor SharedFunctionInfo::SetScript

The previous logic had 2 if-elses, but the branch taken in the first one
determines the branch taken in the second one too (so there are 2 possibilities,
not 4). Make the structure reflect this.

BUG=v8:8015

Change-Id: I75ce86aa9731c0cae21c82f9aad6c83cb950e0d6
Reviewed-on: https://chromium-review.googlesource.com/1163613Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54947}
parent 36bb2e00
...@@ -13858,6 +13858,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, ...@@ -13858,6 +13858,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
// This is okay because the gc-time processing of these lists can tolerate // This is okay because the gc-time processing of these lists can tolerate
// duplicates. // duplicates.
if (script_object->IsScript()) { if (script_object->IsScript()) {
DCHECK(!shared->script()->IsScript());
Handle<Script> script = Handle<Script>::cast(script_object); Handle<Script> script = Handle<Script>::cast(script_object);
Handle<WeakFixedArray> list = Handle<WeakFixedArray> list =
handle(script->shared_function_infos(), isolate); handle(script->shared_function_infos(), isolate);
...@@ -13870,7 +13871,13 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, ...@@ -13870,7 +13871,13 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
} }
#endif #endif
list->Set(function_literal_id, HeapObjectReference::Weak(*shared)); list->Set(function_literal_id, HeapObjectReference::Weak(*shared));
// Remove shared function info from root array.
WeakArrayList* noscript_list =
isolate->heap()->noscript_shared_function_infos();
CHECK(noscript_list->RemoveOne(MaybeObjectHandle::Weak(shared)));
} else { } else {
DCHECK(shared->script()->IsScript());
Handle<WeakArrayList> list = Handle<WeakArrayList> list =
isolate->factory()->noscript_shared_function_infos(); isolate->factory()->noscript_shared_function_infos();
...@@ -13888,9 +13895,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, ...@@ -13888,9 +13895,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
WeakArrayList::AddToEnd(isolate, list, MaybeObjectHandle::Weak(shared)); WeakArrayList::AddToEnd(isolate, list, MaybeObjectHandle::Weak(shared));
isolate->heap()->SetRootNoScriptSharedFunctionInfos(*list); isolate->heap()->SetRootNoScriptSharedFunctionInfos(*list);
}
if (shared->script()->IsScript()) {
// Remove shared function info from old script's list. // Remove shared function info from old script's list.
Script* old_script = Script::cast(shared->script()); Script* old_script = Script::cast(shared->script());
...@@ -13907,10 +13912,6 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared, ...@@ -13907,10 +13912,6 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
ReadOnlyRoots(isolate).undefined_value())); ReadOnlyRoots(isolate).undefined_value()));
} }
} }
} else {
// Remove shared function info from root array.
WeakArrayList* list = isolate->heap()->noscript_shared_function_infos();
CHECK(list->RemoveOne(MaybeObjectHandle::Weak(shared)));
} }
// Finally set new script. // Finally set new script.
......
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