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

Unified Diff: src/factory.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/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index ef34a5539c40efe963473b5feedc163387fca873..759e6e272ae6d8143586d7ec4814f81b4abb0ce2 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());
« no previous file with comments | « src/factory.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698