| 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 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 break; | 2231 break; |
| 2232 } | 2232 } |
| 2233 case KEYED_SUPER_PROPERTY: { | 2233 case KEYED_SUPER_PROPERTY: { |
| 2234 old_value = register_allocator()->NewRegister(); | 2234 old_value = register_allocator()->NewRegister(); |
| 2235 BuildKeyedSuperPropertyLoad(object, home_object, key); | 2235 BuildKeyedSuperPropertyLoad(object, home_object, key); |
| 2236 builder()->StoreAccumulatorInRegister(old_value); | 2236 builder()->StoreAccumulatorInRegister(old_value); |
| 2237 break; | 2237 break; |
| 2238 } | 2238 } |
| 2239 } | 2239 } |
| 2240 VisitForAccumulatorValue(expr->value()); | 2240 VisitForAccumulatorValue(expr->value()); |
| 2241 builder()->BinaryOperation(expr->binary_op(), old_value); | 2241 FeedbackVectorSlot slot = |
| 2242 expr->binary_operation()->BinaryOperationFeedbackSlot(); |
| 2243 builder()->BinaryOperation(expr->binary_op(), old_value, |
| 2244 feedback_index(slot)); |
| 2242 } else { | 2245 } else { |
| 2243 VisitForAccumulatorValue(expr->value()); | 2246 VisitForAccumulatorValue(expr->value()); |
| 2244 } | 2247 } |
| 2245 | 2248 |
| 2246 // Store the value. | 2249 // Store the value. |
| 2247 builder()->SetExpressionPosition(expr); | 2250 builder()->SetExpressionPosition(expr); |
| 2248 FeedbackVectorSlot slot = expr->AssignmentSlot(); | 2251 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
| 2249 switch (assign_type) { | 2252 switch (assign_type) { |
| 2250 case VARIABLE: { | 2253 case VARIABLE: { |
| 2251 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. | 2254 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 | 2876 |
| 2874 // Save result for postfix expressions. | 2877 // Save result for postfix expressions. |
| 2875 if (is_postfix) { | 2878 if (is_postfix) { |
| 2876 old_value = register_allocator()->outer()->NewRegister(); | 2879 old_value = register_allocator()->outer()->NewRegister(); |
| 2877 | 2880 |
| 2878 // Convert old value into a number before saving it. | 2881 // Convert old value into a number before saving it. |
| 2879 builder()->CastAccumulatorToNumber(old_value); | 2882 builder()->CastAccumulatorToNumber(old_value); |
| 2880 } | 2883 } |
| 2881 | 2884 |
| 2882 // Perform +1/-1 operation. | 2885 // Perform +1/-1 operation. |
| 2883 builder()->CountOperation(expr->binary_op()); | 2886 FeedbackVectorSlot slot = expr->CountBinaryOpFeedbackSlot(); |
| 2887 builder()->CountOperation(expr->binary_op(), feedback_index(slot)); |
| 2884 | 2888 |
| 2885 // Store the value. | 2889 // Store the value. |
| 2886 builder()->SetExpressionPosition(expr); | 2890 builder()->SetExpressionPosition(expr); |
| 2887 FeedbackVectorSlot feedback_slot = expr->CountSlot(); | 2891 FeedbackVectorSlot feedback_slot = expr->CountSlot(); |
| 2888 switch (assign_type) { | 2892 switch (assign_type) { |
| 2889 case VARIABLE: { | 2893 case VARIABLE: { |
| 2890 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 2894 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
| 2891 VisitVariableAssignment(variable, expr->op(), feedback_slot); | 2895 VisitVariableAssignment(variable, expr->op(), feedback_slot); |
| 2892 break; | 2896 break; |
| 2893 } | 2897 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2944 builder()->SetExpressionPosition(expr); | 2948 builder()->SetExpressionPosition(expr); |
| 2945 builder()->CompareOperation(expr->op(), lhs); | 2949 builder()->CompareOperation(expr->op(), lhs); |
| 2946 execution_result()->SetResultInAccumulator(); | 2950 execution_result()->SetResultInAccumulator(); |
| 2947 } | 2951 } |
| 2948 | 2952 |
| 2949 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { | 2953 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { |
| 2950 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for | 2954 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for |
| 2951 // +x and -x by the parser. | 2955 // +x and -x by the parser. |
| 2952 Register lhs = VisitForRegisterValue(expr->left()); | 2956 Register lhs = VisitForRegisterValue(expr->left()); |
| 2953 VisitForAccumulatorValue(expr->right()); | 2957 VisitForAccumulatorValue(expr->right()); |
| 2954 builder()->BinaryOperation(expr->op(), lhs); | 2958 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); |
| 2959 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); |
| 2955 execution_result()->SetResultInAccumulator(); | 2960 execution_result()->SetResultInAccumulator(); |
| 2956 } | 2961 } |
| 2957 | 2962 |
| 2958 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } | 2963 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
| 2959 | 2964 |
| 2960 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 2965 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
| 2961 UNREACHABLE(); | 2966 UNREACHABLE(); |
| 2962 } | 2967 } |
| 2963 | 2968 |
| 2964 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { | 2969 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3266 return execution_context()->scope()->language_mode(); | 3271 return execution_context()->scope()->language_mode(); |
| 3267 } | 3272 } |
| 3268 | 3273 |
| 3269 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3274 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
| 3270 return TypeFeedbackVector::GetIndex(slot); | 3275 return TypeFeedbackVector::GetIndex(slot); |
| 3271 } | 3276 } |
| 3272 | 3277 |
| 3273 } // namespace interpreter | 3278 } // namespace interpreter |
| 3274 } // namespace internal | 3279 } // namespace internal |
| 3275 } // namespace v8 | 3280 } // namespace v8 |
| OLD | NEW |