Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: src/runtime/runtime-scopes.cc

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: Changes from review Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/regress/regress-5295.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/regress/regress-5295.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698