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

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

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: relax dchecks Created 4 years, 1 month 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
Index: src/runtime/runtime-scopes.cc
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc
index 0c037db307a60ca994da643e9a2554b462654ced..e6de242b227f8afc3ac4e8ed282b980ff7535c2a 100644
--- a/src/runtime/runtime-scopes.cc
+++ b/src/runtime/runtime-scopes.cc
@@ -232,7 +232,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
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();
@@ -313,7 +313,7 @@ Object* DeclareEvalHelper(Isolate* isolate, Handle<String> name,
}
DCHECK(object->IsJSContextExtensionObject() || object->IsJSGlobalObject());
} else {
- DCHECK(context->IsFunctionContext());
+ DCHECK(context->IsFunctionContext() || context->IsEvalContext());
adamk 2016/11/12 00:26:05 We should never get here for an eval context, sinc
Dan Ehrenberg 2016/12/07 05:41:26 Reverted and added a comment explaining the DCHECK
object =
isolate->factory()->NewJSObject(isolate->context_extension_function());
context->set_extension(*object);
@@ -696,6 +696,16 @@ RUNTIME_FUNCTION(Runtime_NewFunctionContext) {
return *isolate->factory()->NewFunctionContext(length, function);
}
+RUNTIME_FUNCTION(Runtime_NewEvalContext) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 1);
+
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+
+ DCHECK(function->context() == isolate->context());
+ int length = function->shared()->scope_info()->ContextLength();
+ return *isolate->factory()->NewEvalContext(length, function);
+}
RUNTIME_FUNCTION(Runtime_PushWithContext) {
HandleScope scope(isolate);

Powered by Google App Engine
This is Rietveld 408576698