Index: src/ast/scopes.cc |
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc |
index 22402b9c692d35000fd667c1f3d347c560b3d94a..e9a6a48b49d6e80ad62f7510bff21e17d048ade3 100644 |
--- a/src/ast/scopes.cc |
+++ b/src/ast/scopes.cc |
@@ -303,6 +303,7 @@ void Scope::SetDefaults() { |
is_declaration_scope_ = false; |
is_lazily_parsed_ = false; |
+ should_compile_lazily_ = false; |
} |
bool Scope::HasSimpleParameters() { |
@@ -310,6 +311,14 @@ bool Scope::HasSimpleParameters() { |
return !scope->is_function_scope() || scope->has_simple_parameters(); |
} |
+void Scope::SetShouldCompileLazily(bool compile_lazily) { |
+ should_compile_lazily_ = compile_lazily; |
+ for (Scope* inner = inner_scope_; inner != nullptr; inner = inner->sibling_) { |
+ if (inner->is_function_scope()) continue; |
+ inner->SetShouldCompileLazily(compile_lazily); |
+ } |
+} |
+ |
void DeclarationScope::set_asm_module() { |
asm_module_ = true; |
// Mark any existing inner function scopes as asm function scopes. |
@@ -552,6 +561,9 @@ void DeclarationScope::Analyze(ParseInfo* info, AnalyzeMode mode) { |
scope->outer_scope()->scope_type() == SCRIPT_SCOPE || |
scope->outer_scope()->already_resolved_); |
+ // The outer scope is never lazy. |
+ scope->SetShouldCompileLazily(false); |
+ |
scope->AllocateVariables(info, mode); |
// Ensuring that the outer script scope has a scope info avoids having |
@@ -1426,6 +1438,7 @@ void Scope::Print(int n) { |
} |
if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
if (is_lazily_parsed_) Indent(n1, "// lazily parsed\n"); |
+ if (should_compile_lazily_) Indent(n1, "// should compile lazily\n"); |
if (num_stack_slots_ > 0) { |
Indent(n1, "// "); |
PrintF("%d stack slots\n", num_stack_slots_); |
@@ -1906,7 +1919,10 @@ void Scope::AllocateScopeInfosRecursively(Isolate* isolate, AnalyzeMode mode, |
// Allocate ScopeInfos for inner scopes. |
for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { |
- scope->AllocateScopeInfosRecursively(isolate, mode, next_outer_scope); |
+ if (should_compile_lazily_) scope->should_compile_lazily_ = true; |
+ scope->AllocateScopeInfosRecursively( |
+ isolate, scope->is_function_scope() ? AnalyzeMode::kRegular : mode, |
marja
2016/10/06 11:53:06
Why is dropping to kRegular correct here?
jochen (gone - plz use gerrit)
2016/10/06 15:05:04
because the scope iterator that uses the AnalyzeMo
|
+ next_outer_scope); |
} |
} |