Index: src/runtime/runtime-scopes.cc |
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
index 7d4392e834a5337974dac2ce5098b09fb770fd4a..62603ba18a0a9b29ca374175f91ee2781ab0d49c 100644 |
--- a/src/runtime/runtime-scopes.cc |
+++ b/src/runtime/runtime-scopes.cc |
@@ -249,6 +249,12 @@ RUNTIME_FUNCTION(Runtime_DeclareLookupSlot) { |
JSGlobalObject::cast(context_arg->extension()), isolate); |
return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const, |
is_function); |
+ } else if (context->IsScriptContext()) { |
+ DCHECK(context->global_object()->IsJSGlobalObject()); |
+ Handle<JSGlobalObject> global( |
+ JSGlobalObject::cast(context->global_object()), isolate); |
+ return DeclareGlobals(isolate, global, name, value, attr, is_var, is_const, |
+ is_function); |
} |
if (attributes != ABSENT) { |
@@ -324,8 +330,12 @@ RUNTIME_FUNCTION(Runtime_InitializeLegacyConstLookupSlot) { |
// meanwhile. If so, re-introduce the variable in the context extension. |
if (attributes == ABSENT) { |
Handle<Context> declaration_context(context_arg->declaration_context()); |
- DCHECK(declaration_context->has_extension()); |
- holder = handle(declaration_context->extension(), isolate); |
+ if (declaration_context->IsScriptContext()) { |
+ holder = handle(declaration_context->global_object(), isolate); |
+ } else { |
+ DCHECK(declaration_context->has_extension()); |
+ holder = handle(declaration_context->extension(), isolate); |
+ } |
CHECK(holder->IsJSObject()); |
} else { |
// For JSContextExtensionObjects, the initializer can be run multiple times |