| 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/scopes.h" | 7 #include "src/ast/scopes.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 | 1307 |
| 1308 LoopBuilder loop_builder(builder()); | 1308 LoopBuilder loop_builder(builder()); |
| 1309 BytecodeLabel subject_null_label, subject_undefined_label; | 1309 BytecodeLabel subject_null_label, subject_undefined_label; |
| 1310 | 1310 |
| 1311 // Prepare the state for executing ForIn. | 1311 // Prepare the state for executing ForIn. |
| 1312 builder()->SetExpressionAsStatementPosition(stmt->subject()); | 1312 builder()->SetExpressionAsStatementPosition(stmt->subject()); |
| 1313 VisitForAccumulatorValue(stmt->subject()); | 1313 VisitForAccumulatorValue(stmt->subject()); |
| 1314 builder()->JumpIfUndefined(&subject_undefined_label); | 1314 builder()->JumpIfUndefined(&subject_undefined_label); |
| 1315 builder()->JumpIfNull(&subject_null_label); | 1315 builder()->JumpIfNull(&subject_null_label); |
| 1316 Register receiver = register_allocator()->NewRegister(); | 1316 Register receiver = register_allocator()->NewRegister(); |
| 1317 builder()->CastAccumulatorToJSObject(receiver); | 1317 builder()->ConvertAccumulatorToObject(receiver); |
| 1318 | 1318 |
| 1319 register_allocator()->PrepareForConsecutiveAllocations(3); | 1319 register_allocator()->PrepareForConsecutiveAllocations(3); |
| 1320 Register cache_type = register_allocator()->NextConsecutiveRegister(); | 1320 Register cache_type = register_allocator()->NextConsecutiveRegister(); |
| 1321 Register cache_array = register_allocator()->NextConsecutiveRegister(); | 1321 Register cache_array = register_allocator()->NextConsecutiveRegister(); |
| 1322 Register cache_length = register_allocator()->NextConsecutiveRegister(); | 1322 Register cache_length = register_allocator()->NextConsecutiveRegister(); |
| 1323 // Used as kRegTriple and kRegPair in ForInPrepare and ForInNext. | 1323 // Used as kRegTriple and kRegPair in ForInPrepare and ForInNext. |
| 1324 USE(cache_array); | 1324 USE(cache_array); |
| 1325 builder()->ForInPrepare(receiver, cache_type); | 1325 builder()->ForInPrepare(receiver, cache_type); |
| 1326 | 1326 |
| 1327 // Set up loop counter | 1327 // Set up loop counter |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 ObjectLiteral::Property* property = expr->properties()->at(i); | 1548 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1549 | 1549 |
| 1550 // Set-up receiver. | 1550 // Set-up receiver. |
| 1551 Register new_receiver = property->is_static() ? literal : prototype; | 1551 Register new_receiver = property->is_static() ? literal : prototype; |
| 1552 if (new_receiver != old_receiver) { | 1552 if (new_receiver != old_receiver) { |
| 1553 builder()->MoveRegister(new_receiver, receiver); | 1553 builder()->MoveRegister(new_receiver, receiver); |
| 1554 old_receiver = new_receiver; | 1554 old_receiver = new_receiver; |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 VisitForAccumulatorValue(property->key()); | 1557 VisitForAccumulatorValue(property->key()); |
| 1558 builder()->CastAccumulatorToName(key); | 1558 builder()->ConvertAccumulatorToName(key); |
| 1559 // The static prototype property is read only. We handle the non computed | 1559 // The static prototype property is read only. We handle the non computed |
| 1560 // property name case in the parser. Since this is the only case where we | 1560 // property name case in the parser. Since this is the only case where we |
| 1561 // need to check for an own read only property we special case this so we do | 1561 // need to check for an own read only property we special case this so we do |
| 1562 // not need to do this for every property. | 1562 // not need to do this for every property. |
| 1563 if (property->is_static() && property->is_computed_name()) { | 1563 if (property->is_static() && property->is_computed_name()) { |
| 1564 VisitClassLiteralStaticPrototypeWithComputedName(key); | 1564 VisitClassLiteralStaticPrototypeWithComputedName(key); |
| 1565 } | 1565 } |
| 1566 VisitForAccumulatorValue(property->value()); | 1566 VisitForAccumulatorValue(property->value()); |
| 1567 builder()->StoreAccumulatorInRegister(value); | 1567 builder()->StoreAccumulatorInRegister(value); |
| 1568 | 1568 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 Register literal_argument = register_allocator()->NextConsecutiveRegister(); | 1838 Register literal_argument = register_allocator()->NextConsecutiveRegister(); |
| 1839 Register key = register_allocator()->NextConsecutiveRegister(); | 1839 Register key = register_allocator()->NextConsecutiveRegister(); |
| 1840 Register value = register_allocator()->NextConsecutiveRegister(); | 1840 Register value = register_allocator()->NextConsecutiveRegister(); |
| 1841 Register attr = register_allocator()->NextConsecutiveRegister(); | 1841 Register attr = register_allocator()->NextConsecutiveRegister(); |
| 1842 DCHECK(Register::AreContiguous(literal_argument, key, value, attr)); | 1842 DCHECK(Register::AreContiguous(literal_argument, key, value, attr)); |
| 1843 Register set_function_name = | 1843 Register set_function_name = |
| 1844 register_allocator()->NextConsecutiveRegister(); | 1844 register_allocator()->NextConsecutiveRegister(); |
| 1845 | 1845 |
| 1846 builder()->MoveRegister(literal, literal_argument); | 1846 builder()->MoveRegister(literal, literal_argument); |
| 1847 VisitForAccumulatorValue(property->key()); | 1847 VisitForAccumulatorValue(property->key()); |
| 1848 builder()->CastAccumulatorToName(key); | 1848 builder()->ConvertAccumulatorToName(key); |
| 1849 VisitForAccumulatorValue(property->value()); | 1849 VisitForAccumulatorValue(property->value()); |
| 1850 builder()->StoreAccumulatorInRegister(value); | 1850 builder()->StoreAccumulatorInRegister(value); |
| 1851 VisitSetHomeObject(value, literal, property); | 1851 VisitSetHomeObject(value, literal, property); |
| 1852 builder()->LoadLiteral(Smi::FromInt(NONE)).StoreAccumulatorInRegister(attr); | 1852 builder()->LoadLiteral(Smi::FromInt(NONE)).StoreAccumulatorInRegister(attr); |
| 1853 switch (property->kind()) { | 1853 switch (property->kind()) { |
| 1854 case ObjectLiteral::Property::CONSTANT: | 1854 case ObjectLiteral::Property::CONSTANT: |
| 1855 case ObjectLiteral::Property::COMPUTED: | 1855 case ObjectLiteral::Property::COMPUTED: |
| 1856 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1856 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1857 builder() | 1857 builder() |
| 1858 ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName())) | 1858 ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName())) |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2948 BuildKeyedSuperPropertyLoad(object, home_object, key); | 2948 BuildKeyedSuperPropertyLoad(object, home_object, key); |
| 2949 break; | 2949 break; |
| 2950 } | 2950 } |
| 2951 } | 2951 } |
| 2952 | 2952 |
| 2953 // Save result for postfix expressions. | 2953 // Save result for postfix expressions. |
| 2954 if (is_postfix) { | 2954 if (is_postfix) { |
| 2955 old_value = register_allocator()->outer()->NewRegister(); | 2955 old_value = register_allocator()->outer()->NewRegister(); |
| 2956 | 2956 |
| 2957 // Convert old value into a number before saving it. | 2957 // Convert old value into a number before saving it. |
| 2958 builder()->CastAccumulatorToNumber(old_value); | 2958 builder()->ConvertAccumulatorToNumber(old_value); |
| 2959 } | 2959 } |
| 2960 | 2960 |
| 2961 // Perform +1/-1 operation. | 2961 // Perform +1/-1 operation. |
| 2962 FeedbackVectorSlot slot = expr->CountBinaryOpFeedbackSlot(); | 2962 FeedbackVectorSlot slot = expr->CountBinaryOpFeedbackSlot(); |
| 2963 builder()->CountOperation(expr->binary_op(), feedback_index(slot)); | 2963 builder()->CountOperation(expr->binary_op(), feedback_index(slot)); |
| 2964 | 2964 |
| 2965 // Store the value. | 2965 // Store the value. |
| 2966 builder()->SetExpressionPosition(expr); | 2966 builder()->SetExpressionPosition(expr); |
| 2967 FeedbackVectorSlot feedback_slot = expr->CountSlot(); | 2967 FeedbackVectorSlot feedback_slot = expr->CountSlot(); |
| 2968 switch (assign_type) { | 2968 switch (assign_type) { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 VisitFunctionClosureForContext(); | 3197 VisitFunctionClosureForContext(); |
| 3198 builder()->CreateBlockContext(scope->scope_info()); | 3198 builder()->CreateBlockContext(scope->scope_info()); |
| 3199 execution_result()->SetResultInAccumulator(); | 3199 execution_result()->SetResultInAccumulator(); |
| 3200 } | 3200 } |
| 3201 | 3201 |
| 3202 void BytecodeGenerator::VisitNewLocalWithContext() { | 3202 void BytecodeGenerator::VisitNewLocalWithContext() { |
| 3203 AccumulatorResultScope accumulator_execution_result(this); | 3203 AccumulatorResultScope accumulator_execution_result(this); |
| 3204 | 3204 |
| 3205 Register extension_object = register_allocator()->NewRegister(); | 3205 Register extension_object = register_allocator()->NewRegister(); |
| 3206 | 3206 |
| 3207 builder()->CastAccumulatorToJSObject(extension_object); | 3207 builder()->ConvertAccumulatorToObject(extension_object); |
| 3208 VisitFunctionClosureForContext(); | 3208 VisitFunctionClosureForContext(); |
| 3209 builder()->CreateWithContext(extension_object); | 3209 builder()->CreateWithContext(extension_object); |
| 3210 execution_result()->SetResultInAccumulator(); | 3210 execution_result()->SetResultInAccumulator(); |
| 3211 } | 3211 } |
| 3212 | 3212 |
| 3213 void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) { | 3213 void BytecodeGenerator::VisitNewLocalCatchContext(Variable* variable) { |
| 3214 AccumulatorResultScope accumulator_execution_result(this); | 3214 AccumulatorResultScope accumulator_execution_result(this); |
| 3215 DCHECK(variable->IsContextSlot()); | 3215 DCHECK(variable->IsContextSlot()); |
| 3216 | 3216 |
| 3217 Register exception = register_allocator()->NewRegister(); | 3217 Register exception = register_allocator()->NewRegister(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3392 return execution_context()->scope()->language_mode(); | 3392 return execution_context()->scope()->language_mode(); |
| 3393 } | 3393 } |
| 3394 | 3394 |
| 3395 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3395 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3396 return TypeFeedbackVector::GetIndex(slot); | 3396 return TypeFeedbackVector::GetIndex(slot); |
| 3397 } | 3397 } |
| 3398 | 3398 |
| 3399 } // namespace interpreter | 3399 } // namespace interpreter |
| 3400 } // namespace internal | 3400 } // namespace internal |
| 3401 } // namespace v8 | 3401 } // namespace v8 |
| OLD | NEW |