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

Unified Diff: src/ast/scopes.cc

Issue 2583163002: Force ctxt allocation in eval scopes. (Closed)
Patch Set: moar Created 3 years, 12 months 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 | « no previous file | test/mjsunit/regress/regress-5736.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 36f5b8bbf3179fe495ff42309f777ee1a70095ff..48ddd0a53a51a23386c82681b8a6c27a0169eb6b 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -1178,7 +1178,10 @@ bool Scope::AllowsLazyParsingWithoutUnresolvedVariables(
// the parse, since context allocation of those variables is already
// guaranteed to be correct.
for (const Scope* s = this; s != outer; s = s->outer_scope_) {
- if (s->is_eval_scope()) return false;
+ // Eval forces context allocation on all outer scopes, so we don't need to
+ // look at those scopes. Sloppy eval makes top-level non-lexical variables
+ // dynamic, whereas strict-mode requires context allocation.
+ if (s->is_eval_scope()) return is_sloppy(s->language_mode());
// Catch scopes force context allocation of all variables.
if (s->is_catch_scope()) continue;
// With scopes do not introduce variables that need allocation.
@@ -1888,7 +1891,10 @@ bool Scope::MustAllocateInContext(Variable* var) {
if (has_forced_context_allocation()) return true;
if (var->mode() == TEMPORARY) return false;
if (is_catch_scope()) return true;
- if (is_script_scope() && IsLexicalVariableMode(var->mode())) return true;
+ if ((is_script_scope() || is_eval_scope()) &&
+ IsLexicalVariableMode(var->mode())) {
+ return true;
+ }
return var->has_forced_context_allocation() || inner_scope_calls_eval_;
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-5736.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698