| 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/scopes.h" | 5 #include "src/scopes.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/messages.h" | 9 #include "src/messages.h" |
| 10 #include "src/parser.h" | 10 #include "src/parser.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 scope_contains_with_ = false; | 187 scope_contains_with_ = false; |
| 188 scope_calls_eval_ = false; | 188 scope_calls_eval_ = false; |
| 189 scope_uses_arguments_ = false; | 189 scope_uses_arguments_ = false; |
| 190 scope_uses_super_property_ = false; | 190 scope_uses_super_property_ = false; |
| 191 asm_module_ = false; | 191 asm_module_ = false; |
| 192 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 192 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
| 193 // Inherit the language mode from the parent scope. | 193 // Inherit the language mode from the parent scope. |
| 194 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 194 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; |
| 195 outer_scope_calls_sloppy_eval_ = false; | 195 outer_scope_calls_sloppy_eval_ = false; |
| 196 inner_scope_calls_eval_ = false; | 196 inner_scope_calls_eval_ = false; |
| 197 inner_scope_uses_arguments_ = false; | |
| 198 scope_nonlinear_ = false; | 197 scope_nonlinear_ = false; |
| 199 force_eager_compilation_ = false; | 198 force_eager_compilation_ = false; |
| 200 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) | 199 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
| 201 ? outer_scope->has_forced_context_allocation() : false; | 200 ? outer_scope->has_forced_context_allocation() : false; |
| 202 num_var_or_const_ = 0; | 201 num_var_or_const_ = 0; |
| 203 num_stack_slots_ = 0; | 202 num_stack_slots_ = 0; |
| 204 num_heap_slots_ = 0; | 203 num_heap_slots_ = 0; |
| 205 num_global_slots_ = 0; | 204 num_global_slots_ = 0; |
| 206 num_modules_ = 0; | 205 num_modules_ = 0; |
| 207 module_var_ = NULL; | 206 module_var_ = NULL; |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 Indent(n1, "// strong mode scope\n"); | 990 Indent(n1, "// strong mode scope\n"); |
| 992 } else if (is_strict(language_mode())) { | 991 } else if (is_strict(language_mode())) { |
| 993 Indent(n1, "// strict mode scope\n"); | 992 Indent(n1, "// strict mode scope\n"); |
| 994 } | 993 } |
| 995 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 994 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
| 996 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 995 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |
| 997 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 996 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
| 998 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 997 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); |
| 999 if (scope_uses_super_property_) | 998 if (scope_uses_super_property_) |
| 1000 Indent(n1, "// scope uses 'super' property\n"); | 999 Indent(n1, "// scope uses 'super' property\n"); |
| 1001 if (inner_scope_uses_arguments_) { | |
| 1002 Indent(n1, "// inner scope uses 'arguments'\n"); | |
| 1003 } | |
| 1004 if (outer_scope_calls_sloppy_eval_) { | 1000 if (outer_scope_calls_sloppy_eval_) { |
| 1005 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 1001 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); |
| 1006 } | 1002 } |
| 1007 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 1003 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
| 1008 if (num_stack_slots_ > 0) { | 1004 if (num_stack_slots_ > 0) { |
| 1009 Indent(n1, "// "); | 1005 Indent(n1, "// "); |
| 1010 PrintF("%d stack slots\n", num_stack_slots_); | 1006 PrintF("%d stack slots\n", num_stack_slots_); |
| 1011 } | 1007 } |
| 1012 if (num_heap_slots_ > 0) { | 1008 if (num_heap_slots_ > 0) { |
| 1013 Indent(n1, "// "); | 1009 Indent(n1, "// "); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 } | 1336 } |
| 1341 | 1337 |
| 1342 bool calls_sloppy_eval = | 1338 bool calls_sloppy_eval = |
| 1343 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_; | 1339 this->calls_sloppy_eval() || outer_scope_calls_sloppy_eval_; |
| 1344 for (int i = 0; i < inner_scopes_.length(); i++) { | 1340 for (int i = 0; i < inner_scopes_.length(); i++) { |
| 1345 Scope* inner = inner_scopes_[i]; | 1341 Scope* inner = inner_scopes_[i]; |
| 1346 inner->PropagateScopeInfo(calls_sloppy_eval); | 1342 inner->PropagateScopeInfo(calls_sloppy_eval); |
| 1347 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) { | 1343 if (inner->scope_calls_eval_ || inner->inner_scope_calls_eval_) { |
| 1348 inner_scope_calls_eval_ = true; | 1344 inner_scope_calls_eval_ = true; |
| 1349 } | 1345 } |
| 1350 // If the inner scope is an arrow function, propagate the flags tracking | |
| 1351 // usage of arguments/super/this, but do not propagate them out from normal | |
| 1352 // functions. | |
| 1353 if (!inner->is_function_scope() || inner->is_arrow_scope()) { | |
| 1354 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { | |
| 1355 inner_scope_uses_arguments_ = true; | |
| 1356 } | |
| 1357 } | |
| 1358 if (inner->force_eager_compilation_) { | 1346 if (inner->force_eager_compilation_) { |
| 1359 force_eager_compilation_ = true; | 1347 force_eager_compilation_ = true; |
| 1360 } | 1348 } |
| 1361 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { | 1349 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { |
| 1362 inner->asm_function_ = true; | 1350 inner->asm_function_ = true; |
| 1363 } | 1351 } |
| 1364 } | 1352 } |
| 1365 } | 1353 } |
| 1366 | 1354 |
| 1367 | 1355 |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 function_ != NULL && function_->proxy()->var()->IsContextSlot(); | 1652 function_ != NULL && function_->proxy()->var()->IsContextSlot(); |
| 1665 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - | 1653 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - num_global_slots() - |
| 1666 (is_function_var_in_context ? 1 : 0); | 1654 (is_function_var_in_context ? 1 : 0); |
| 1667 } | 1655 } |
| 1668 | 1656 |
| 1669 | 1657 |
| 1670 int Scope::ContextGlobalCount() const { return num_global_slots(); } | 1658 int Scope::ContextGlobalCount() const { return num_global_slots(); } |
| 1671 | 1659 |
| 1672 } // namespace internal | 1660 } // namespace internal |
| 1673 } // namespace v8 | 1661 } // namespace v8 |
| OLD | NEW |