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

Unified Diff: src/factory.cc

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: Clean up test 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
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 8b08b426d3985fe83bb6c68047cc0500b366a6b0..77039ee2665379e288a8a3041f4ad04d4cffea0d 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -889,13 +889,24 @@ Handle<Context> Factory::NewModuleContext(Handle<Module> module,
return context;
}
-
Handle<Context> Factory::NewFunctionContext(int length,
- Handle<JSFunction> function) {
- DCHECK(function->shared()->scope_info()->scope_type() == FUNCTION_SCOPE);
+ Handle<JSFunction> function,
+ ScopeType scope_type) {
+ DCHECK(function->shared()->scope_info()->scope_type() == scope_type);
DCHECK(length >= Context::MIN_CONTEXT_SLOTS);
Handle<FixedArray> array = NewFixedArray(length);
- array->set_map_no_write_barrier(*function_context_map());
+ Handle<Map> map;
+ switch (scope_type) {
+ case EVAL_SCOPE:
+ map = eval_context_map();
+ break;
+ case FUNCTION_SCOPE:
+ map = function_context_map();
+ break;
+ default:
+ UNREACHABLE();
+ }
+ array->set_map_no_write_barrier(*map);
Handle<Context> context = Handle<Context>::cast(array);
context->set_closure(*function);
context->set_previous(function->context());

Powered by Google App Engine
This is Rietveld 408576698