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 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 builder()->LoadLookupGlobalSlot(variable->name(), typeof_mode, | 1859 builder()->LoadLookupGlobalSlot(variable->name(), typeof_mode, |
1860 feedback_index(slot), depth); | 1860 feedback_index(slot), depth); |
1861 break; | 1861 break; |
1862 } | 1862 } |
1863 default: | 1863 default: |
1864 builder()->LoadLookupSlot(variable->name(), typeof_mode); | 1864 builder()->LoadLookupSlot(variable->name(), typeof_mode); |
1865 } | 1865 } |
1866 break; | 1866 break; |
1867 } | 1867 } |
1868 case VariableLocation::MODULE: { | 1868 case VariableLocation::MODULE: { |
1869 Register index = register_allocator()->NewRegister(); | 1869 builder()->LoadModuleVariable(variable->index()); |
1870 builder() | |
1871 ->LoadLiteral(Smi::FromInt(variable->index())) | |
1872 .StoreAccumulatorInRegister(index) | |
1873 .CallRuntime(Runtime::kLoadModuleVariable, index); | |
1874 if (hole_check_mode == HoleCheckMode::kRequired) { | 1870 if (hole_check_mode == HoleCheckMode::kRequired) { |
1875 BuildThrowIfHole(variable->name()); | 1871 BuildThrowIfHole(variable->name()); |
1876 } | 1872 } |
1877 break; | 1873 break; |
1878 } | 1874 } |
1879 } | 1875 } |
1880 } | 1876 } |
1881 | 1877 |
1882 void BytecodeGenerator::BuildVariableLoadForAccumulatorValue( | 1878 void BytecodeGenerator::BuildVariableLoadForAccumulatorValue( |
1883 Variable* variable, FeedbackVectorSlot slot, HoleCheckMode hole_check_mode, | 1879 Variable* variable, FeedbackVectorSlot slot, HoleCheckMode hole_check_mode, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 if (mode == CONST && op != Token::INIT) { | 2027 if (mode == CONST && op != Token::INIT) { |
2032 builder()->CallRuntime(Runtime::kThrowConstAssignError); | 2028 builder()->CallRuntime(Runtime::kThrowConstAssignError); |
2033 break; | 2029 break; |
2034 } | 2030 } |
2035 | 2031 |
2036 // If we don't throw above, we know that we're dealing with an | 2032 // If we don't throw above, we know that we're dealing with an |
2037 // export because imports are const and we do not generate initializing | 2033 // export because imports are const and we do not generate initializing |
2038 // assignments for them. | 2034 // assignments for them. |
2039 DCHECK(variable->IsExport()); | 2035 DCHECK(variable->IsExport()); |
2040 | 2036 |
2041 RegisterList args = register_allocator()->NewRegisterList(2); | |
2042 builder() | |
2043 ->StoreAccumulatorInRegister(args[1]) | |
2044 .LoadLiteral(Smi::FromInt(variable->index())) | |
2045 .StoreAccumulatorInRegister(args[0]); | |
2046 if (hole_check_mode == HoleCheckMode::kRequired) { | 2037 if (hole_check_mode == HoleCheckMode::kRequired) { |
2047 builder()->CallRuntime(Runtime::kLoadModuleVariable, args[0]); | 2038 Register value_temp = register_allocator()->NewRegister(); |
| 2039 builder() |
| 2040 ->StoreAccumulatorInRegister(value_temp) |
| 2041 .LoadModuleVariable(variable->index()); |
2048 BuildHoleCheckForVariableAssignment(variable, op); | 2042 BuildHoleCheckForVariableAssignment(variable, op); |
| 2043 builder()->LoadAccumulatorWithRegister(value_temp); |
2049 } | 2044 } |
2050 builder() | 2045 builder()->StoreModuleVariable(variable->index()); |
2051 ->CallRuntime(Runtime::kStoreModuleVariable, args) | |
2052 .LoadAccumulatorWithRegister(args[1]); | |
2053 break; | 2046 break; |
2054 } | 2047 } |
2055 } | 2048 } |
2056 } | 2049 } |
2057 | 2050 |
2058 void BytecodeGenerator::VisitAssignment(Assignment* expr) { | 2051 void BytecodeGenerator::VisitAssignment(Assignment* expr) { |
2059 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); | 2052 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
2060 Register object, key; | 2053 Register object, key; |
2061 RegisterList super_property_args; | 2054 RegisterList super_property_args; |
2062 Handle<String> name; | 2055 Handle<String> name; |
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3196 } | 3189 } |
3197 | 3190 |
3198 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { | 3191 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { |
3199 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict | 3192 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict |
3200 : Runtime::kStoreKeyedToSuper_Sloppy; | 3193 : Runtime::kStoreKeyedToSuper_Sloppy; |
3201 } | 3194 } |
3202 | 3195 |
3203 } // namespace interpreter | 3196 } // namespace interpreter |
3204 } // namespace internal | 3197 } // namespace internal |
3205 } // namespace v8 | 3198 } // namespace v8 |
OLD | NEW |