Index: src/runtime/runtime-scopes.cc |
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
index 3161b83455ffafb2ee9f817f2c2126146dcae305..30f497c00f55add8e399b4514615ab76166a65d8 100644 |
--- a/src/runtime/runtime-scopes.cc |
+++ b/src/runtime/runtime-scopes.cc |
@@ -223,15 +223,15 @@ namespace { |
Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, |
Handle<Object> value) { |
- // Declarations are always made in a function, native, or script context, or |
- // a declaration block scope. Since this is called from eval, the context |
- // passed is the context of the caller, which may be some nested context and |
- // not the declaration context. |
+ // Declarations are always made in a function, native, eval, or script |
+ // context, or a declaration block scope. Since this is called from eval, the |
+ // context passed is the context of the caller, which may be some nested |
+ // context and not the declaration context. |
Handle<Context> context_arg(isolate->context(), isolate); |
Handle<Context> context(context_arg->declaration_context(), isolate); |
DCHECK(context->IsFunctionContext() || context->IsNativeContext() || |
- context->IsScriptContext() || |
+ context->IsScriptContext() || context->IsEvalContext() || |
(context->IsBlockContext() && context->has_extension())); |
bool is_function = value->IsJSFunction(); |
@@ -312,6 +312,8 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name, |
} |
DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject()); |
} else { |
+ // Sloppy eval will never have an extension object, as vars are hoisted out, |
+ // and lets are known statically. |
DCHECK(context->IsFunctionContext()); |
object = |
isolate->factory()->NewJSObject(isolate->context_extension_function()); |
@@ -701,19 +703,19 @@ RUNTIME_FUNCTION(Runtime_NewScriptContext) { |
return *result; |
} |
- |
RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
HandleScope scope(isolate); |
- DCHECK(args.length() == 1); |
+ DCHECK(args.length() == 2); |
CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
+ CONVERT_SMI_ARG_CHECKED(scope_type, 1); |
DCHECK(function->context() == isolate->context()); |
int length = function->shared()->scope_info()->ContextLength(); |
- return *isolate->factory()->NewFunctionContext(length, function); |
+ return *isolate->factory()->NewFunctionContext( |
+ length, function, static_cast<ScopeType>(scope_type)); |
} |
- |
RUNTIME_FUNCTION(Runtime_PushWithContext) { |
HandleScope scope(isolate); |
DCHECK_EQ(3, args.length()); |