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/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/bytecode-flags.h" | 10 #include "src/interpreter/bytecode-flags.h" |
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 break; | 2237 break; |
2238 } | 2238 } |
2239 case KEYED_SUPER_PROPERTY: { | 2239 case KEYED_SUPER_PROPERTY: { |
2240 old_value = register_allocator()->NewRegister(); | 2240 old_value = register_allocator()->NewRegister(); |
2241 BuildKeyedSuperPropertyLoad(object, home_object, key); | 2241 BuildKeyedSuperPropertyLoad(object, home_object, key); |
2242 builder()->StoreAccumulatorInRegister(old_value); | 2242 builder()->StoreAccumulatorInRegister(old_value); |
2243 break; | 2243 break; |
2244 } | 2244 } |
2245 } | 2245 } |
2246 VisitForAccumulatorValue(expr->value()); | 2246 VisitForAccumulatorValue(expr->value()); |
2247 builder()->BinaryOperation(expr->binary_op(), old_value); | 2247 FeedbackVectorSlot slot = |
| 2248 expr->binary_operation()->BinaryOperationFeedbackSlot(); |
| 2249 builder()->BinaryOperation(expr->binary_op(), old_value, |
| 2250 feedback_index(slot)); |
2248 } else { | 2251 } else { |
2249 VisitForAccumulatorValue(expr->value()); | 2252 VisitForAccumulatorValue(expr->value()); |
2250 } | 2253 } |
2251 | 2254 |
2252 // Store the value. | 2255 // Store the value. |
2253 builder()->SetExpressionPosition(expr); | 2256 builder()->SetExpressionPosition(expr); |
2254 FeedbackVectorSlot slot = expr->AssignmentSlot(); | 2257 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
2255 switch (assign_type) { | 2258 switch (assign_type) { |
2256 case VARIABLE: { | 2259 case VARIABLE: { |
2257 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. | 2260 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 | 2882 |
2880 // Save result for postfix expressions. | 2883 // Save result for postfix expressions. |
2881 if (is_postfix) { | 2884 if (is_postfix) { |
2882 old_value = register_allocator()->outer()->NewRegister(); | 2885 old_value = register_allocator()->outer()->NewRegister(); |
2883 | 2886 |
2884 // Convert old value into a number before saving it. | 2887 // Convert old value into a number before saving it. |
2885 builder()->CastAccumulatorToNumber(old_value); | 2888 builder()->CastAccumulatorToNumber(old_value); |
2886 } | 2889 } |
2887 | 2890 |
2888 // Perform +1/-1 operation. | 2891 // Perform +1/-1 operation. |
2889 builder()->CountOperation(expr->binary_op()); | 2892 FeedbackVectorSlot slot = expr->CountBinaryOpFeedbackSlot(); |
| 2893 builder()->CountOperation(expr->binary_op(), feedback_index(slot)); |
2890 | 2894 |
2891 // Store the value. | 2895 // Store the value. |
2892 builder()->SetExpressionPosition(expr); | 2896 builder()->SetExpressionPosition(expr); |
2893 FeedbackVectorSlot feedback_slot = expr->CountSlot(); | 2897 FeedbackVectorSlot feedback_slot = expr->CountSlot(); |
2894 switch (assign_type) { | 2898 switch (assign_type) { |
2895 case VARIABLE: { | 2899 case VARIABLE: { |
2896 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 2900 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
2897 VisitVariableAssignment(variable, expr->op(), feedback_slot); | 2901 VisitVariableAssignment(variable, expr->op(), feedback_slot); |
2898 break; | 2902 break; |
2899 } | 2903 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2950 builder()->SetExpressionPosition(expr); | 2954 builder()->SetExpressionPosition(expr); |
2951 builder()->CompareOperation(expr->op(), lhs); | 2955 builder()->CompareOperation(expr->op(), lhs); |
2952 execution_result()->SetResultInAccumulator(); | 2956 execution_result()->SetResultInAccumulator(); |
2953 } | 2957 } |
2954 | 2958 |
2955 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { | 2959 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { |
2956 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for | 2960 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for |
2957 // +x and -x by the parser. | 2961 // +x and -x by the parser. |
2958 Register lhs = VisitForRegisterValue(expr->left()); | 2962 Register lhs = VisitForRegisterValue(expr->left()); |
2959 VisitForAccumulatorValue(expr->right()); | 2963 VisitForAccumulatorValue(expr->right()); |
2960 builder()->BinaryOperation(expr->op(), lhs); | 2964 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); |
| 2965 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); |
2961 execution_result()->SetResultInAccumulator(); | 2966 execution_result()->SetResultInAccumulator(); |
2962 } | 2967 } |
2963 | 2968 |
2964 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } | 2969 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
2965 | 2970 |
2966 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 2971 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
2967 UNREACHABLE(); | 2972 UNREACHABLE(); |
2968 } | 2973 } |
2969 | 2974 |
2970 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { | 2975 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3271 return execution_context()->scope()->language_mode(); | 3276 return execution_context()->scope()->language_mode(); |
3272 } | 3277 } |
3273 | 3278 |
3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3279 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3275 return TypeFeedbackVector::GetIndex(slot); | 3280 return TypeFeedbackVector::GetIndex(slot); |
3276 } | 3281 } |
3277 | 3282 |
3278 } // namespace interpreter | 3283 } // namespace interpreter |
3279 } // namespace internal | 3284 } // namespace internal |
3280 } // namespace v8 | 3285 } // namespace v8 |
OLD | NEW |