Commit 367b0c1e authored by Victor Gomes's avatar Victor Gomes Committed by Commit Bot

[runtime] Change default scope info for SyntheticFunctionContexts

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: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68636}
parent f6726358
...@@ -12961,8 +12961,7 @@ void CodeStubAssembler::InitializeSyntheticFunctionContext( ...@@ -12961,8 +12961,7 @@ void CodeStubAssembler::InitializeSyntheticFunctionContext(
SmiConstant(slots)); SmiConstant(slots));
TNode<Context> context = CAST(context_heap_object); TNode<Context> context = CAST(context_heap_object);
const TNode<Object> empty_scope_info = const TNode<Object> empty_scope_info = LoadRoot(RootIndex::kEmptyScopeInfo);
LoadContextElement(native_context, Context::SCOPE_INFO_INDEX);
StoreContextElementNoWriteBarrier(context, Context::SCOPE_INFO_INDEX, StoreContextElementNoWriteBarrier(context, Context::SCOPE_INFO_INDEX,
empty_scope_info); empty_scope_info);
StoreContextElementNoWriteBarrier(context, Context::PREVIOUS_INDEX, StoreContextElementNoWriteBarrier(context, Context::PREVIOUS_INDEX,
......
...@@ -2491,7 +2491,7 @@ TEST(CreatePromiseResolvingFunctionsContext) { ...@@ -2491,7 +2491,7 @@ TEST(CreatePromiseResolvingFunctionsContext) {
ft.Call(isolate->factory()->undefined_value()).ToHandleChecked(); ft.Call(isolate->factory()->undefined_value()).ToHandleChecked();
CHECK(result->IsContext()); CHECK(result->IsContext());
Handle<Context> context_js = Handle<Context>::cast(result); 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_EQ(*isolate->native_context(), context_js->native_context());
CHECK(context_js->get(PromiseBuiltins::kPromiseSlot).IsJSPromise()); CHECK(context_js->get(PromiseBuiltins::kPromiseSlot).IsJSPromise());
CHECK_EQ(ReadOnlyRoots(isolate).false_value(), CHECK_EQ(ReadOnlyRoots(isolate).false_value(),
...@@ -2649,7 +2649,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) { ...@@ -2649,7 +2649,7 @@ TEST(CreatePromiseGetCapabilitiesExecutorContext) {
CHECK(result_obj->IsContext()); CHECK(result_obj->IsContext());
Handle<Context> context_js = Handle<Context>::cast(result_obj); Handle<Context> context_js = Handle<Context>::cast(result_obj);
CHECK_EQ(PromiseBuiltins::kCapabilitiesContextLength, context_js->length()); 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_EQ(*isolate->native_context(), context_js->native_context());
CHECK( CHECK(
context_js->get(PromiseBuiltins::kCapabilitySlot).IsPromiseCapability()); context_js->get(PromiseBuiltins::kCapabilitySlot).IsPromiseCapability());
...@@ -2698,7 +2698,8 @@ TEST(NewPromiseCapability) { ...@@ -2698,7 +2698,8 @@ TEST(NewPromiseCapability) {
for (auto&& callback : callbacks) { for (auto&& callback : callbacks) {
Handle<Context> context(Context::cast(callback->context()), isolate); 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(*isolate->native_context(), context->native_context());
CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length()); CHECK_EQ(PromiseBuiltins::kPromiseContextLength, context->length());
CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise()); CHECK_EQ(context->get(PromiseBuiltins::kPromiseSlot), result->promise());
......
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