Commit e553a440 authored by Seth Brenith's avatar Seth Brenith Committed by V8 LUCI CQ

Build ScopeInfo in the right order for web snapshots

Currently, WebSnapshotDeserializer::CreateScopeInfo creates the
ScopeInfo first, and then creates its local names hashtable if
necessary. If GC occurs when creating the local names hashtable, the
object verifier correctly complains that the ScopeInfo doesn't have all
needed fields. The solution (consistent with ScopeInfo::Create) is to
create the local names hashtable first. That way, no GC can happen in
the interval after the ScopeInfo is allocated but before it has valid
fields.

Bug: v8:13135
Change-Id: Ifd6eb10e54a4151f7edb592bc19afa3263d41788
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3803674Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82155}
parent 9d7e8ea3
......@@ -2661,8 +2661,12 @@ Handle<ScopeInfo> WebSnapshotDeserializer::CreateScopeInfo(
: 0) +
(has_parent ? 1 : 0) + local_names_container_size +
variable_count;
Handle<ScopeInfo> scope_info = factory()->NewScopeInfo(length);
Handle<NameToIndexHashTable> local_names_hashtable;
if (!has_inlined_local_names) {
local_names_hashtable = NameToIndexHashTable::New(isolate_, variable_count,
AllocationType::kOld);
}
Handle<ScopeInfo> scope_info = factory()->NewScopeInfo(length);
{
DisallowGarbageCollection no_gc;
ScopeInfo raw = *scope_info;
......@@ -2676,11 +2680,9 @@ Handle<ScopeInfo> WebSnapshotDeserializer::CreateScopeInfo(
if (raw.HasPositionInfo()) {
raw.SetPositionInfo(0, 0);
}
}
if (!has_inlined_local_names) {
local_names_hashtable = NameToIndexHashTable::New(isolate_, variable_count,
AllocationType::kOld);
scope_info->set_context_local_names_hashtable(*local_names_hashtable);
if (!has_inlined_local_names) {
raw.set_context_local_names_hashtable(*local_names_hashtable);
}
}
return scope_info;
}
......
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