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 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2203 break; | 2203 break; |
2204 } | 2204 } |
2205 case KEYED_SUPER_PROPERTY: { | 2205 case KEYED_SUPER_PROPERTY: { |
2206 old_value = register_allocator()->NewRegister(); | 2206 old_value = register_allocator()->NewRegister(); |
2207 BuildKeyedSuperPropertyLoad(object, home_object, key); | 2207 BuildKeyedSuperPropertyLoad(object, home_object, key); |
2208 builder()->StoreAccumulatorInRegister(old_value); | 2208 builder()->StoreAccumulatorInRegister(old_value); |
2209 break; | 2209 break; |
2210 } | 2210 } |
2211 } | 2211 } |
2212 VisitForAccumulatorValue(expr->value()); | 2212 VisitForAccumulatorValue(expr->value()); |
2213 builder()->BinaryOperation(expr->binary_op(), old_value); | 2213 int feedback_slot_index = |
2214 feedback_index(expr->binary_operation()->BinaryOperationFeedbackSlot()); | |
rmcilroy
2016/08/03 16:04:30
nit - keep variable as "FeedbackVectorSlot slot" a
mythria
2016/08/05 07:08:15
Done.
| |
2215 builder()->BinaryOperation(expr->binary_op(), old_value, | |
2216 feedback_slot_index); | |
2214 } else { | 2217 } else { |
2215 VisitForAccumulatorValue(expr->value()); | 2218 VisitForAccumulatorValue(expr->value()); |
2216 } | 2219 } |
2217 | 2220 |
2218 // Store the value. | 2221 // Store the value. |
2219 builder()->SetExpressionPosition(expr); | 2222 builder()->SetExpressionPosition(expr); |
2220 FeedbackVectorSlot slot = expr->AssignmentSlot(); | 2223 FeedbackVectorSlot slot = expr->AssignmentSlot(); |
2221 switch (assign_type) { | 2224 switch (assign_type) { |
2222 case VARIABLE: { | 2225 case VARIABLE: { |
2223 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. | 2226 // TODO(oth): The VisitVariableAssignment() call is hard to reason about. |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2845 | 2848 |
2846 // Save result for postfix expressions. | 2849 // Save result for postfix expressions. |
2847 if (is_postfix) { | 2850 if (is_postfix) { |
2848 old_value = register_allocator()->outer()->NewRegister(); | 2851 old_value = register_allocator()->outer()->NewRegister(); |
2849 | 2852 |
2850 // Convert old value into a number before saving it. | 2853 // Convert old value into a number before saving it. |
2851 builder()->CastAccumulatorToNumber(old_value); | 2854 builder()->CastAccumulatorToNumber(old_value); |
2852 } | 2855 } |
2853 | 2856 |
2854 // Perform +1/-1 operation. | 2857 // Perform +1/-1 operation. |
2855 builder()->CountOperation(expr->binary_op()); | 2858 int feedback_slot_index = feedback_index(expr->CountBinaryOpFeedbackSlot()); |
rmcilroy
2016/08/03 16:04:29
ditto
mythria
2016/08/05 07:08:14
Done.
| |
2859 builder()->CountOperation(expr->binary_op(), feedback_slot_index); | |
2856 | 2860 |
2857 // Store the value. | 2861 // Store the value. |
2858 builder()->SetExpressionPosition(expr); | 2862 builder()->SetExpressionPosition(expr); |
2859 FeedbackVectorSlot feedback_slot = expr->CountSlot(); | 2863 FeedbackVectorSlot feedback_slot = expr->CountSlot(); |
2860 switch (assign_type) { | 2864 switch (assign_type) { |
2861 case VARIABLE: { | 2865 case VARIABLE: { |
2862 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 2866 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
2863 VisitVariableAssignment(variable, expr->op(), feedback_slot); | 2867 VisitVariableAssignment(variable, expr->op(), feedback_slot); |
2864 break; | 2868 break; |
2865 } | 2869 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2916 builder()->SetExpressionPosition(expr); | 2920 builder()->SetExpressionPosition(expr); |
2917 builder()->CompareOperation(expr->op(), lhs); | 2921 builder()->CompareOperation(expr->op(), lhs); |
2918 execution_result()->SetResultInAccumulator(); | 2922 execution_result()->SetResultInAccumulator(); |
2919 } | 2923 } |
2920 | 2924 |
2921 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { | 2925 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { |
2922 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for | 2926 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for |
2923 // +x and -x by the parser. | 2927 // +x and -x by the parser. |
2924 Register lhs = VisitForRegisterValue(expr->left()); | 2928 Register lhs = VisitForRegisterValue(expr->left()); |
2925 VisitForAccumulatorValue(expr->right()); | 2929 VisitForAccumulatorValue(expr->right()); |
2926 builder()->BinaryOperation(expr->op(), lhs); | 2930 int feedback_slot_index = feedback_index(expr->BinaryOperationFeedbackSlot()); |
rmcilroy
2016/08/03 16:04:30
ditto
mythria
2016/08/05 07:08:14
Done.
| |
2931 builder()->BinaryOperation(expr->op(), lhs, feedback_slot_index); | |
2927 execution_result()->SetResultInAccumulator(); | 2932 execution_result()->SetResultInAccumulator(); |
2928 } | 2933 } |
2929 | 2934 |
2930 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } | 2935 void BytecodeGenerator::VisitSpread(Spread* expr) { UNREACHABLE(); } |
2931 | 2936 |
2932 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { | 2937 void BytecodeGenerator::VisitEmptyParentheses(EmptyParentheses* expr) { |
2933 UNREACHABLE(); | 2938 UNREACHABLE(); |
2934 } | 2939 } |
2935 | 2940 |
2936 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { | 2941 void BytecodeGenerator::VisitThisFunction(ThisFunction* expr) { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3237 return execution_context()->scope()->language_mode(); | 3242 return execution_context()->scope()->language_mode(); |
3238 } | 3243 } |
3239 | 3244 |
3240 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3245 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3241 return TypeFeedbackVector::GetIndex(slot); | 3246 return TypeFeedbackVector::GetIndex(slot); |
3242 } | 3247 } |
3243 | 3248 |
3244 } // namespace interpreter | 3249 } // namespace interpreter |
3245 } // namespace internal | 3250 } // namespace internal |
3246 } // namespace v8 | 3251 } // namespace v8 |
OLD | NEW |