OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
10 #include "src/ast/ast.h" | 10 #include "src/ast/ast.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 variables_(zone), | 108 variables_(zone), |
109 locals_(4, zone), | 109 locals_(4, zone), |
110 decls_(4, zone), | 110 decls_(4, zone), |
111 scope_type_(scope_type) { | 111 scope_type_(scope_type) { |
112 DCHECK_NE(SCRIPT_SCOPE, scope_type); | 112 DCHECK_NE(SCRIPT_SCOPE, scope_type); |
113 SetDefaults(); | 113 SetDefaults(); |
114 set_language_mode(outer_scope->language_mode()); | 114 set_language_mode(outer_scope->language_mode()); |
115 force_context_allocation_ = | 115 force_context_allocation_ = |
116 !is_function_scope() && outer_scope->has_forced_context_allocation(); | 116 !is_function_scope() && outer_scope->has_forced_context_allocation(); |
117 outer_scope_->AddInnerScope(this); | 117 outer_scope_->AddInnerScope(this); |
| 118 if (outer_scope_->is_lazily_parsed_) is_lazily_parsed_ = true; |
118 } | 119 } |
119 | 120 |
120 Scope::Snapshot::Snapshot(Scope* scope) | 121 Scope::Snapshot::Snapshot(Scope* scope) |
121 : outer_scope_(scope), | 122 : outer_scope_(scope), |
122 top_inner_scope_(scope->inner_scope_), | 123 top_inner_scope_(scope->inner_scope_), |
123 top_unresolved_(scope->unresolved_), | 124 top_unresolved_(scope->unresolved_), |
124 top_local_(scope->GetClosureScope()->locals_.length()), | 125 top_local_(scope->GetClosureScope()->locals_.length()), |
125 top_decl_(scope->GetClosureScope()->decls_.length()) {} | 126 top_decl_(scope->GetClosureScope()->decls_.length()) {} |
126 | 127 |
127 DeclarationScope::DeclarationScope(Zone* zone, | 128 DeclarationScope::DeclarationScope(Zone* zone, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 276 |
276 scope_calls_eval_ = false; | 277 scope_calls_eval_ = false; |
277 scope_nonlinear_ = false; | 278 scope_nonlinear_ = false; |
278 is_hidden_ = false; | 279 is_hidden_ = false; |
279 is_debug_evaluate_scope_ = false; | 280 is_debug_evaluate_scope_ = false; |
280 | 281 |
281 inner_scope_calls_eval_ = false; | 282 inner_scope_calls_eval_ = false; |
282 force_context_allocation_ = false; | 283 force_context_allocation_ = false; |
283 | 284 |
284 is_declaration_scope_ = false; | 285 is_declaration_scope_ = false; |
| 286 |
| 287 is_lazily_parsed_ = false; |
285 } | 288 } |
286 | 289 |
287 bool Scope::HasSimpleParameters() { | 290 bool Scope::HasSimpleParameters() { |
288 DeclarationScope* scope = GetClosureScope(); | 291 DeclarationScope* scope = GetClosureScope(); |
289 return !scope->is_function_scope() || scope->has_simple_parameters(); | 292 return !scope->is_function_scope() || scope->has_simple_parameters(); |
290 } | 293 } |
291 | 294 |
292 void DeclarationScope::set_asm_module() { | 295 void DeclarationScope::set_asm_module() { |
293 asm_module_ = true; | 296 asm_module_ = true; |
294 // Mark any existing inner function scopes as asm function scopes. | 297 // Mark any existing inner function scopes as asm function scopes. |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 DCHECK(!proxy->is_resolved()); | 1163 DCHECK(!proxy->is_resolved()); |
1161 VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy); | 1164 VariableProxy* copy = ast_node_factory->CopyVariableProxy(proxy); |
1162 migrate_to->AddUnresolved(copy); | 1165 migrate_to->AddUnresolved(copy); |
1163 } | 1166 } |
1164 | 1167 |
1165 // Push scope data up to migrate_to. Note that migrate_to and this Scope | 1168 // Push scope data up to migrate_to. Note that migrate_to and this Scope |
1166 // describe the same Scope, just in different Zones. | 1169 // describe the same Scope, just in different Zones. |
1167 PropagateUsageFlagsToScope(migrate_to); | 1170 PropagateUsageFlagsToScope(migrate_to); |
1168 if (scope_uses_super_property_) migrate_to->scope_uses_super_property_ = true; | 1171 if (scope_uses_super_property_) migrate_to->scope_uses_super_property_ = true; |
1169 if (inner_scope_calls_eval_) migrate_to->inner_scope_calls_eval_ = true; | 1172 if (inner_scope_calls_eval_) migrate_to->inner_scope_calls_eval_ = true; |
| 1173 if (is_lazily_parsed_) migrate_to->is_lazily_parsed_ = true; |
1170 DCHECK(!force_eager_compilation_); | 1174 DCHECK(!force_eager_compilation_); |
1171 migrate_to->set_start_position(start_position_); | 1175 migrate_to->set_start_position(start_position_); |
1172 migrate_to->set_end_position(end_position_); | 1176 migrate_to->set_end_position(end_position_); |
1173 migrate_to->set_language_mode(language_mode()); | 1177 migrate_to->set_language_mode(language_mode()); |
1174 migrate_to->arity_ = arity_; | 1178 migrate_to->arity_ = arity_; |
1175 migrate_to->force_context_allocation_ = force_context_allocation_; | 1179 migrate_to->force_context_allocation_ = force_context_allocation_; |
1176 outer_scope_->RemoveInnerScope(this); | 1180 outer_scope_->RemoveInnerScope(this); |
1177 DCHECK_EQ(outer_scope_, migrate_to->outer_scope_); | 1181 DCHECK_EQ(outer_scope_, migrate_to->outer_scope_); |
1178 DCHECK_EQ(outer_scope_->zone(), migrate_to->zone()); | 1182 DCHECK_EQ(outer_scope_->zone(), migrate_to->zone()); |
1179 DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject()); | 1183 DCHECK_EQ(NeedsHomeObject(), migrate_to->NeedsHomeObject()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 if (is_strict(language_mode())) { | 1325 if (is_strict(language_mode())) { |
1322 Indent(n1, "// strict mode scope\n"); | 1326 Indent(n1, "// strict mode scope\n"); |
1323 } | 1327 } |
1324 if (IsAsmModule()) Indent(n1, "// scope is an asm module\n"); | 1328 if (IsAsmModule()) Indent(n1, "// scope is an asm module\n"); |
1325 if (IsAsmFunction()) Indent(n1, "// scope is an asm function\n"); | 1329 if (IsAsmFunction()) Indent(n1, "// scope is an asm function\n"); |
1326 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 1330 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
1327 if (is_declaration_scope() && AsDeclarationScope()->uses_super_property()) { | 1331 if (is_declaration_scope() && AsDeclarationScope()->uses_super_property()) { |
1328 Indent(n1, "// scope uses 'super' property\n"); | 1332 Indent(n1, "// scope uses 'super' property\n"); |
1329 } | 1333 } |
1330 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 1334 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
| 1335 if (is_lazily_parsed_) Indent(n1, "// lazily parsed\n"); |
1331 if (num_stack_slots_ > 0) { | 1336 if (num_stack_slots_ > 0) { |
1332 Indent(n1, "// "); | 1337 Indent(n1, "// "); |
1333 PrintF("%d stack slots\n", num_stack_slots_); | 1338 PrintF("%d stack slots\n", num_stack_slots_); |
1334 } | 1339 } |
1335 if (num_heap_slots_ > 0) { | 1340 if (num_heap_slots_ > 0) { |
1336 Indent(n1, "// "); | 1341 Indent(n1, "// "); |
1337 PrintF("%d heap slots\n", num_heap_slots_); | 1342 PrintF("%d heap slots\n", num_heap_slots_); |
1338 } | 1343 } |
1339 | 1344 |
1340 // Print locals. | 1345 // Print locals. |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 Variable* function = | 1816 Variable* function = |
1812 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; | 1817 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; |
1813 bool is_function_var_in_context = | 1818 bool is_function_var_in_context = |
1814 function != nullptr && function->IsContextSlot(); | 1819 function != nullptr && function->IsContextSlot(); |
1815 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1820 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
1816 (is_function_var_in_context ? 1 : 0); | 1821 (is_function_var_in_context ? 1 : 0); |
1817 } | 1822 } |
1818 | 1823 |
1819 } // namespace internal | 1824 } // namespace internal |
1820 } // namespace v8 | 1825 } // namespace v8 |
OLD | NEW |