Skip to content

Commit

Permalink
[runtime] Change default scope info for SyntheticFunctionContexts
Browse files Browse the repository at this point in the history
This changes the default scope info for SyntheticFunctionContexts
to the EmptyScopeInfo which does not contain an extension slot.

The bug happened because, previously, the native context scope info
was used as dummy.

Change-Id: I4d6bf6918c11c79201d16bde99ed76800ad6f6c5
Bug: v8:10629
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2277806
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68636}
  • Loading branch information
victorgomes authored and Commit Bot committed Jul 1, 2020
1 parent f672635 commit 367b0c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/codegen/code-stub-assembler.cc
Expand Up @@ -12961,8 +12961,7 @@ void CodeStubAssembler::InitializeSyntheticFunctionContext(
SmiConstant(slots));

TNode<Context> context = CAST(context_heap_object);
const TNode<Object> empty_scope_info =
LoadContextElement(native_context, Context::SCOPE_INFO_INDEX);
const TNode<Object> empty_scope_info = LoadRoot(RootIndex::kEmptyScopeInfo);
StoreContextElementNoWriteBarrier(context, Context::SCOPE_INFO_INDEX,
empty_scope_info);
StoreContextElementNoWriteBarrier(context, Context::PREVIOUS_INDEX,
Expand Down
7 changes: 4 additions & 3 deletions test/cctest/test-code-stub-assembler.cc
Expand Up @@ -2491,7 +2491,7 @@ TEST(CreatePromiseResolvingFunctionsContext) {
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK(result->IsContext());
Handle<Context> context_js = Handle<Context>::cast(result);
CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info());
CHECK_EQ(isolate->root(RootIndex::kEmptyScopeInfo), context_js->scope_info());
CHECK_EQ(*isolate->native_context(), context_js->native_context());
CHECK(context_js->get(PromiseBuiltins::kPromiseSlot).IsJSPromise());
CHECK_EQ(ReadOnlyRoots(isolate).false_value(),
Expand Down Expand Up @@ -2649,7 +2649,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) {
CHECK(result_obj->IsContext());
Handle<Context> context_js = Handle<Context>::cast(result_obj);
CHECK_EQ(PromiseBuiltins::kCapabilitiesContextLength, context_js->length());
CHECK_EQ(isolate->native_context()->scope_info(), context_js->scope_info());
CHECK_EQ(isolate->root(RootIndex::kEmptyScopeInfo), context_js->scope_info());
CHECK_EQ(*isolate->native_context(), context_js->native_context());
CHECK(
context_js->get(PromiseBuiltins::kCapabilitySlot).IsPromiseCapability());
Expand Down Expand Up @@ -2698,7 +2698,8 @@ TEST(NewPromiseCapability) {

for (auto&& callback : callbacks) {
Handle<Context> context(Context::cast(callback->context()), isolate);
CHECK_EQ(isolate->native_context()->scope_info(), context->scope_info());
CHECK_EQ(isolate->root(RootIndex::kEmptyScopeInfo),
context->scope_info());
CHECK_EQ(*isolate->native_context(), context->native_context());
CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length());
CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise());
Expand Down

0 comments on commit 367b0c1

Please sign in to comment.