| 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/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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 illegal_redecl_ = nullptr; | 163 illegal_redecl_ = nullptr; |
| 164 scope_inside_with_ = false; | 164 scope_inside_with_ = false; |
| 165 scope_contains_with_ = false; | 165 scope_contains_with_ = false; |
| 166 scope_calls_eval_ = false; | 166 scope_calls_eval_ = false; |
| 167 scope_uses_arguments_ = false; | 167 scope_uses_arguments_ = false; |
| 168 scope_uses_super_property_ = false; | 168 scope_uses_super_property_ = false; |
| 169 asm_module_ = false; | 169 asm_module_ = false; |
| 170 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; | 170 asm_function_ = outer_scope != NULL && outer_scope->asm_module_; |
| 171 // Inherit the language mode from the parent scope. | 171 // Inherit the language mode from the parent scope. |
| 172 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; | 172 language_mode_ = outer_scope != NULL ? outer_scope->language_mode_ : SLOPPY; |
| 173 asm_mode_ = (outer_scope == NULL || outer_scope->asm_mode_ == ASM_NO) |
| 174 ? ASM_NO |
| 175 : (scope_type == FUNCTION_SCOPE ? ASM_FUNCTION : outer_scope->asm_mode_); |
| 173 outer_scope_calls_sloppy_eval_ = false; | 176 outer_scope_calls_sloppy_eval_ = false; |
| 174 inner_scope_calls_eval_ = false; | 177 inner_scope_calls_eval_ = false; |
| 175 inner_scope_uses_arguments_ = false; | 178 inner_scope_uses_arguments_ = false; |
| 176 force_eager_compilation_ = false; | 179 force_eager_compilation_ = asm_mode_ == ASM_FUNCTION; |
| 177 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) | 180 force_context_allocation_ = (outer_scope != NULL && !is_function_scope()) |
| 178 ? outer_scope->has_forced_context_allocation() : false; | 181 ? outer_scope->has_forced_context_allocation() : false; |
| 179 num_var_or_const_ = 0; | 182 num_var_or_const_ = 0; |
| 180 num_stack_slots_ = 0; | 183 num_stack_slots_ = 0; |
| 181 num_heap_slots_ = 0; | 184 num_heap_slots_ = 0; |
| 182 num_modules_ = 0; | 185 num_modules_ = 0; |
| 183 module_var_ = NULL, | 186 module_var_ = NULL, |
| 184 rest_parameter_ = NULL; | 187 rest_parameter_ = NULL; |
| 185 rest_index_ = -1; | 188 rest_index_ = -1; |
| 186 scope_info_ = scope_info; | 189 scope_info_ = scope_info; |
| 187 start_position_ = RelocInfo::kNoPosition; | 190 start_position_ = RelocInfo::kNoPosition; |
| 188 end_position_ = RelocInfo::kNoPosition; | 191 end_position_ = RelocInfo::kNoPosition; |
| 189 if (!scope_info.is_null()) { | 192 if (!scope_info.is_null()) { |
| 190 scope_calls_eval_ = scope_info->CallsEval(); | 193 scope_calls_eval_ = scope_info->CallsEval(); |
| 191 language_mode_ = scope_info->language_mode(); | 194 language_mode_ = scope_info->language_mode(); |
| 195 asm_mode_ = scope_info->asm_mode(); |
| 192 block_scope_is_class_scope_ = scope_info->block_scope_is_class_scope(); | 196 block_scope_is_class_scope_ = scope_info->block_scope_is_class_scope(); |
| 193 function_kind_ = scope_info->function_kind(); | 197 function_kind_ = scope_info->function_kind(); |
| 194 } | 198 } |
| 195 } | 199 } |
| 196 | 200 |
| 197 | 201 |
| 198 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, | 202 Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone, |
| 199 Context* context, Scope* script_scope) { | 203 Context* context, Scope* script_scope) { |
| 200 // Reconstruct the outer scope chain from a closure's context chain. | 204 // Reconstruct the outer scope chain from a closure's context chain. |
| 201 Scope* current_scope = NULL; | 205 Scope* current_scope = NULL; |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 914 | 918 |
| 915 // Scope info. | 919 // Scope info. |
| 916 if (HasTrivialOuterContext()) { | 920 if (HasTrivialOuterContext()) { |
| 917 Indent(n1, "// scope has trivial outer context\n"); | 921 Indent(n1, "// scope has trivial outer context\n"); |
| 918 } | 922 } |
| 919 if (is_strong(language_mode())) { | 923 if (is_strong(language_mode())) { |
| 920 Indent(n1, "// strong mode scope\n"); | 924 Indent(n1, "// strong mode scope\n"); |
| 921 } else if (is_strict(language_mode())) { | 925 } else if (is_strict(language_mode())) { |
| 922 Indent(n1, "// strict mode scope\n"); | 926 Indent(n1, "// strict mode scope\n"); |
| 923 } | 927 } |
| 928 if (asm_mode() == ASM_FUNCTION) { |
| 929 Indent(n1, "// asm function\n"); |
| 930 } else if (asm_mode() == ASM_MODULE) { |
| 931 Indent(n1, "// asm module\n"); |
| 932 } |
| 924 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); | 933 if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n"); |
| 925 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); | 934 if (scope_contains_with_) Indent(n1, "// scope contains 'with'\n"); |
| 926 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); | 935 if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n"); |
| 927 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); | 936 if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n"); |
| 928 if (scope_uses_super_property_) | 937 if (scope_uses_super_property_) |
| 929 Indent(n1, "// scope uses 'super' property\n"); | 938 Indent(n1, "// scope uses 'super' property\n"); |
| 930 if (inner_scope_uses_arguments_) { | 939 if (inner_scope_uses_arguments_) { |
| 931 Indent(n1, "// inner scope uses 'arguments'\n"); | 940 Indent(n1, "// inner scope uses 'arguments'\n"); |
| 932 } | 941 } |
| 933 if (outer_scope_calls_sloppy_eval_) { | 942 if (outer_scope_calls_sloppy_eval_) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 inner_scope_calls_eval_ = true; | 1289 inner_scope_calls_eval_ = true; |
| 1281 } | 1290 } |
| 1282 // If the inner scope is an arrow function, propagate the flags tracking | 1291 // If the inner scope is an arrow function, propagate the flags tracking |
| 1283 // usage of arguments/super/this, but do not propagate them out from normal | 1292 // usage of arguments/super/this, but do not propagate them out from normal |
| 1284 // functions. | 1293 // functions. |
| 1285 if (!inner->is_function_scope() || inner->is_arrow_scope()) { | 1294 if (!inner->is_function_scope() || inner->is_arrow_scope()) { |
| 1286 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { | 1295 if (inner->scope_uses_arguments_ || inner->inner_scope_uses_arguments_) { |
| 1287 inner_scope_uses_arguments_ = true; | 1296 inner_scope_uses_arguments_ = true; |
| 1288 } | 1297 } |
| 1289 } | 1298 } |
| 1299 // TODO(bradnelson): |
| 1300 // Do we want to prevent propagating if this is an ASM function? |
| 1290 if (inner->force_eager_compilation_) { | 1301 if (inner->force_eager_compilation_) { |
| 1291 force_eager_compilation_ = true; | 1302 force_eager_compilation_ = true; |
| 1292 } | 1303 } |
| 1293 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { | 1304 if (asm_module_ && inner->scope_type() == FUNCTION_SCOPE) { |
| 1294 inner->asm_function_ = true; | 1305 inner->asm_function_ = true; |
| 1295 } | 1306 } |
| 1296 } | 1307 } |
| 1297 } | 1308 } |
| 1298 | 1309 |
| 1299 | 1310 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 } | 1575 } |
| 1565 | 1576 |
| 1566 | 1577 |
| 1567 int Scope::ContextLocalCount() const { | 1578 int Scope::ContextLocalCount() const { |
| 1568 if (num_heap_slots() == 0) return 0; | 1579 if (num_heap_slots() == 0) return 0; |
| 1569 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - | 1580 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - |
| 1570 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); | 1581 (function_ != NULL && function_->proxy()->var()->IsContextSlot() ? 1 : 0); |
| 1571 } | 1582 } |
| 1572 } // namespace internal | 1583 } // namespace internal |
| 1573 } // namespace v8 | 1584 } // namespace v8 |
| OLD | NEW |