Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 36f5b8bbf3179fe495ff42309f777ee1a70095ff..73e0575141768ae881f4cfa92384494297a38687 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_strict(s->language_mode()); |
adamk
2017/01/03 19:49:05
Nit:
!is_strict(...)
could be
is_sloppy(...)
marja
2017/01/03 19:55:50
Done.
|
// 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_; |
} |