| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/scopes.h" | 7 #include "src/scopes.h" |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 receiver_ = NULL; | 150 receiver_ = NULL; |
| 151 new_target_ = nullptr; | 151 new_target_ = nullptr; |
| 152 function_ = NULL; | 152 function_ = NULL; |
| 153 arguments_ = NULL; | 153 arguments_ = NULL; |
| 154 illegal_redecl_ = NULL; | 154 illegal_redecl_ = NULL; |
| 155 scope_inside_with_ = false; | 155 scope_inside_with_ = false; |
| 156 scope_contains_with_ = false; | 156 scope_contains_with_ = false; |
| 157 scope_calls_eval_ = false; | 157 scope_calls_eval_ = false; |
| 158 scope_uses_arguments_ = false; | 158 scope_uses_arguments_ = false; |
| 159 scope_uses_super_property_ = false; | 159 scope_uses_super_property_ = false; |
| 160 scope_uses_super_constructor_call_ = false; | |
| 161 scope_uses_this_ = false; | 160 scope_uses_this_ = false; |
| 162 asm_module_ = false; | 161 asm_module_ = false; |
| 163 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 162 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
| 164 // Inherit the language mode from the parent scope. | 163 // Inherit the language mode from the parent scope. |
| 165 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 164 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; |
| 166 outer_scope_calls_sloppy_eval_ = false; | 165 outer_scope_calls_sloppy_eval_ = false; |
| 167 inner_scope_calls_eval_ = false; | 166 inner_scope_calls_eval_ = false; |
| 168 inner_scope_uses_arguments_ = false; | 167 inner_scope_uses_arguments_ = false; |
| 169 inner_scope_uses_this_ = false; | 168 inner_scope_uses_this_ = false; |
| 170 inner_scope_uses_super_property_ = false; | 169 inner_scope_uses_super_property_ = false; |
| 171 inner_scope_uses_super_constructor_call_ = false; | |
| 172 force_eager_compilation_ = false; | 170 force_eager_compilation_ = false; |
| 173 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) | 171 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
| 174 ? outer_scope->has_forced_context_allocation() : false; | 172 ? outer_scope->has_forced_context_allocation() : false; |
| 175 num_var_or_const_ = 0; | 173 num_var_or_const_ = 0; |
| 176 num_stack_slots_ = 0; | 174 num_stack_slots_ = 0; |
| 177 num_heap_slots_ = 0; | 175 num_heap_slots_ = 0; |
| 178 num_modules_ = 0; | 176 num_modules_ = 0; |
| 179 module_var_ = NULL, | 177 module_var_ = NULL, |
| 180 rest_parameter_ = NULL; | 178 rest_parameter_ = NULL; |
| 181 rest_index_ = -1; | 179 rest_index_ = -1; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 362 } |
| 365 | 363 |
| 366 // Move unresolved variables | 364 // Move unresolved variables |
| 367 for (int i = 0; i < unresolved_.length(); i++) { | 365 for (int i = 0; i < unresolved_.length(); i++) { |
| 368 outer_scope()->unresolved_.Add(unresolved_[i], zone()); | 366 outer_scope()->unresolved_.Add(unresolved_[i], zone()); |
| 369 } | 367 } |
| 370 | 368 |
| 371 // Propagate usage flags to outer scope. | 369 // Propagate usage flags to outer scope. |
| 372 if (uses_arguments()) outer_scope_->RecordArgumentsUsage(); | 370 if (uses_arguments()) outer_scope_->RecordArgumentsUsage(); |
| 373 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage(); | 371 if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage(); |
| 374 if (uses_super_constructor_call()) { | |
| 375 outer_scope_->RecordSuperConstructorCallUsage(); | |
| 376 } | |
| 377 if (uses_this()) outer_scope_->RecordThisUsage(); | 372 if (uses_this()) outer_scope_->RecordThisUsage(); |
| 378 | 373 |
| 379 return NULL; | 374 return NULL; |
| 380 } | 375 } |
| 381 | 376 |
| 382 | 377 |
| 383 Variable* Scope::LookupLocal(const AstRawString* name) { | 378 Variable* Scope::LookupLocal(const AstRawString* name) { |
| 384 Variable* result = variables_.Lookup(name); | 379 Variable* result = variables_.Lookup(name); |
| 385 if (result != NULL || scope_info_.is_null()) { | 380 if (result != NULL || scope_info_.is_null()) { |
| 386 return result; | 381 return result; |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 Indent(n1, "// strong mode scope\n"); | 891 Indent(n1, "// strong mode scope\n"); |
| 897 } else if (is_strict(language_mode())) { | 892 } else if (is_strict(language_mode())) { |
| 898 Indent(n1, "// strict mode scope\n"); | 893 Indent(n1, "// strict mode scope\n"); |
| 899 } | 894 } |
| 900 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 895 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
| 901 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 896 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |
| 902 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 897 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
| 903 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 898 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); |
| 904 if (scope_uses_super_property_) | 899 if (scope_uses_super_property_) |
| 905 Indent(n1, "// scope uses 'super' property\n"); | 900 Indent(n1, "// scope uses 'super' property\n"); |
| 906 if (scope_uses_super_constructor_call_) | |
| 907 Indent(n1, "// scope uses 'super' constructor\n"); | |
| 908 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n"); | 901 if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n"); |
| 909 if (inner_scope_uses_arguments_) { | 902 if (inner_scope_uses_arguments_) { |
| 910 Indent(n1, "// inner scope uses 'arguments'\n"); | 903 Indent(n1, "// inner scope uses 'arguments'\n"); |
| 911 } | 904 } |
| 912 if (inner_scope_uses_super_property_) | 905 if (inner_scope_uses_super_property_) |
| 913 Indent(n1, "// inner scope uses 'super' property\n"); | 906 Indent(n1, "// inner scope uses 'super' property\n"); |
| 914 if (inner_scope_uses_super_constructor_call_) { | |
| 915 Indent(n1, "// inner scope uses 'super' constructor\n"); | |
| 916 } | |
| 917 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n"); | 907 if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n"); |
| 918 if (outer_scope_calls_sloppy_eval_) { | 908 if (outer_scope_calls_sloppy_eval_) { |
| 919 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); | 909 Indent(n1, "// outer scope calls 'eval' in sloppy context\n"); |
| 920 } | 910 } |
| 921 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); | 911 if (inner_scope_calls_eval_) Indent(n1, "// inner scope calls 'eval'\n"); |
| 922 if (num_stack_slots_ > 0) { Indent(n1, "// "); | 912 if (num_stack_slots_ > 0) { Indent(n1, "// "); |
| 923 PrintF("%d stack slots\n", num_stack_slots_); } | 913 PrintF("%d stack slots\n", num_stack_slots_); } |
| 924 if (num_heap_slots_ > 0) { Indent(n1, "// "); | 914 if (num_heap_slots_ > 0) { Indent(n1, "// "); |
| 925 PrintF("%d heap slots\n", num_heap_slots_); } | 915 PrintF("%d heap slots\n", num_heap_slots_); } |
| 926 | 916 |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 // usage of arguments/super/this, but do not propagate them out from normal | 1173 // usage of arguments/super/this, but do not propagate them out from normal |
| 1184 // functions. | 1174 // functions. |
| 1185 if (!inner->is_function_scope() || inner->is_arrow_scope()) { | 1175 if (!inner->is_function_scope() || inner->is_arrow_scope()) { |
| 1186 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { | 1176 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { |
| 1187 inner_scope_uses_arguments_ = true; | 1177 inner_scope_uses_arguments_ = true; |
| 1188 } | 1178 } |
| 1189 if (inner->scope_uses_super_property_ || | 1179 if (inner->scope_uses_super_property_ || |
| 1190 inner->inner_scope_uses_super_property_) { | 1180 inner->inner_scope_uses_super_property_) { |
| 1191 inner_scope_uses_super_property_ = true; | 1181 inner_scope_uses_super_property_ = true; |
| 1192 } | 1182 } |
| 1193 if (inner->uses_super_constructor_call() || | |
| 1194 inner->inner_scope_uses_super_constructor_call_) { | |
| 1195 inner_scope_uses_super_constructor_call_ = true; | |
| 1196 } | |
| 1197 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) { | 1183 if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) { |
| 1198 inner_scope_uses_this_ = true; | 1184 inner_scope_uses_this_ = true; |
| 1199 } | 1185 } |
| 1200 } | 1186 } |
| 1201 if (inner->force_eager_compilation_) { | 1187 if (inner->force_eager_compilation_) { |
| 1202 force_eager_compilation_ = true; | 1188 force_eager_compilation_ = true; |
| 1203 } | 1189 } |
| 1204 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { | 1190 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { |
| 1205 inner->asm_function_ = true; | 1191 inner->asm_function_ = true; |
| 1206 } | 1192 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 } | 1425 } |
| 1440 | 1426 |
| 1441 | 1427 |
| 1442 int Scope::ContextLocalCount() const { | 1428 int Scope::ContextLocalCount() const { |
| 1443 if (num_heap_slots() == 0) return 0; | 1429 if (num_heap_slots() == 0) return 0; |
| 1444 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1430 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1445 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1431 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
| 1446 } | 1432 } |
| 1447 | 1433 |
| 1448 } } // namespace v8::internal | 1434 } } // namespace v8::internal |
| OLD | NEW |