| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
| 6 | 6 |
| 7 #include "src/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-info.h" | 10 #include "src/compilation-info.h" |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 execution_result_(nullptr), | 581 execution_result_(nullptr), |
| 582 generator_resume_points_(info->literal()->yield_count(), info->zone()), | 582 generator_resume_points_(info->literal()->yield_count(), info->zone()), |
| 583 generator_state_(), | 583 generator_state_(), |
| 584 loop_depth_(0), | 584 loop_depth_(0), |
| 585 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), | 585 home_object_symbol_(info->isolate()->factory()->home_object_symbol()), |
| 586 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) { | 586 empty_fixed_array_(info->isolate()->factory()->empty_fixed_array()) { |
| 587 AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory(); | 587 AstValueFactory* ast_value_factory = info->parse_info()->ast_value_factory(); |
| 588 const AstRawString* prototype_string = ast_value_factory->prototype_string(); | 588 const AstRawString* prototype_string = ast_value_factory->prototype_string(); |
| 589 ast_value_factory->Internalize(info->isolate()); | 589 ast_value_factory->Internalize(info->isolate()); |
| 590 prototype_string_ = prototype_string->string(); | 590 prototype_string_ = prototype_string->string(); |
| 591 undefined_string_ = ast_value_factory->undefined_string(); |
| 591 } | 592 } |
| 592 | 593 |
| 593 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { | 594 Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(Isolate* isolate) { |
| 594 AllocateDeferredConstants(); | 595 AllocateDeferredConstants(); |
| 595 if (HasStackOverflow()) return Handle<BytecodeArray>(); | 596 if (HasStackOverflow()) return Handle<BytecodeArray>(); |
| 596 return builder()->ToBytecodeArray(isolate); | 597 return builder()->ToBytecodeArray(isolate); |
| 597 } | 598 } |
| 598 | 599 |
| 599 void BytecodeGenerator::AllocateDeferredConstants() { | 600 void BytecodeGenerator::AllocateDeferredConstants() { |
| 600 // Build global declaration pair arrays. | 601 // Build global declaration pair arrays. |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 // We need to load the variable into the accumulator, even when in a | 1825 // We need to load the variable into the accumulator, even when in a |
| 1825 // VisitForRegisterScope, in order to avoid register aliasing if | 1826 // VisitForRegisterScope, in order to avoid register aliasing if |
| 1826 // subsequent expressions assign to the same variable. | 1827 // subsequent expressions assign to the same variable. |
| 1827 builder()->LoadAccumulatorWithRegister(source); | 1828 builder()->LoadAccumulatorWithRegister(source); |
| 1828 if (hole_check_mode == HoleCheckMode::kRequired) { | 1829 if (hole_check_mode == HoleCheckMode::kRequired) { |
| 1829 BuildThrowIfHole(variable->name()); | 1830 BuildThrowIfHole(variable->name()); |
| 1830 } | 1831 } |
| 1831 break; | 1832 break; |
| 1832 } | 1833 } |
| 1833 case VariableLocation::UNALLOCATED: { | 1834 case VariableLocation::UNALLOCATED: { |
| 1834 builder()->LoadGlobal(variable->name(), feedback_index(slot), | 1835 // The global identifier "undefined" is immutable. Everything |
| 1835 typeof_mode); | 1836 // else could be reassigned. For performance, we do a pointer comparison |
| 1837 // rather than checking if the raw_name is really "undefined". |
| 1838 if (variable->raw_name() == undefined_string()) { |
| 1839 builder()->LoadUndefined(); |
| 1840 } else { |
| 1841 builder()->LoadGlobal(variable->name(), feedback_index(slot), |
| 1842 typeof_mode); |
| 1843 } |
| 1836 break; | 1844 break; |
| 1837 } | 1845 } |
| 1838 case VariableLocation::CONTEXT: { | 1846 case VariableLocation::CONTEXT: { |
| 1839 int depth = execution_context()->ContextChainDepth(variable->scope()); | 1847 int depth = execution_context()->ContextChainDepth(variable->scope()); |
| 1840 ContextScope* context = execution_context()->Previous(depth); | 1848 ContextScope* context = execution_context()->Previous(depth); |
| 1841 Register context_reg; | 1849 Register context_reg; |
| 1842 if (context) { | 1850 if (context) { |
| 1843 context_reg = context->reg(); | 1851 context_reg = context->reg(); |
| 1844 depth = 0; | 1852 depth = 0; |
| 1845 } else { | 1853 } else { |
| (...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3198 } | 3206 } |
| 3199 | 3207 |
| 3200 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3208 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
| 3201 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3209 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
| 3202 : Runtime::kStoreKeyedToSuper_Sloppy; | 3210 : Runtime::kStoreKeyedToSuper_Sloppy; |
| 3203 } | 3211 } |
| 3204 | 3212 |
| 3205 } // namespace interpreter | 3213 } // namespace interpreter |
| 3206 } // namespace internal | 3214 } // namespace internal |
| 3207 } // namespace v8 | 3215 } // namespace v8 |
| OLD | NEW |