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 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 CaseClause* clause = clauses->at(i); | 1116 CaseClause* clause = clauses->at(i); |
1117 | 1117 |
1118 // The default is not a test, remember index. | 1118 // The default is not a test, remember index. |
1119 if (clause->is_default()) { | 1119 if (clause->is_default()) { |
1120 default_index = i; | 1120 default_index = i; |
1121 continue; | 1121 continue; |
1122 } | 1122 } |
1123 | 1123 |
1124 // Perform label comparison as if via '===' with tag. | 1124 // Perform label comparison as if via '===' with tag. |
1125 VisitForAccumulatorValue(clause->label()); | 1125 VisitForAccumulatorValue(clause->label()); |
1126 builder()->CompareOperation(Token::Value::EQ_STRICT, tag); | 1126 builder()->CompareOperation( |
| 1127 Token::Value::EQ_STRICT, tag, |
| 1128 feedback_index(clause->CompareOperationFeedbackSlot())); |
1127 switch_builder.Case(i); | 1129 switch_builder.Case(i); |
1128 } | 1130 } |
1129 | 1131 |
1130 if (default_index >= 0) { | 1132 if (default_index >= 0) { |
1131 // Emit default jump if there is a default case. | 1133 // Emit default jump if there is a default case. |
1132 switch_builder.DefaultAt(default_index); | 1134 switch_builder.DefaultAt(default_index); |
1133 } else { | 1135 } else { |
1134 // Otherwise if we have reached here none of the cases matched, so jump to | 1136 // Otherwise if we have reached here none of the cases matched, so jump to |
1135 // the end. | 1137 // the end. |
1136 switch_builder.Break(); | 1138 switch_builder.Break(); |
(...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3024 default: | 3026 default: |
3025 VisitArithmeticExpression(binop); | 3027 VisitArithmeticExpression(binop); |
3026 break; | 3028 break; |
3027 } | 3029 } |
3028 } | 3030 } |
3029 | 3031 |
3030 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { | 3032 void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
3031 Register lhs = VisitForRegisterValue(expr->left()); | 3033 Register lhs = VisitForRegisterValue(expr->left()); |
3032 VisitForAccumulatorValue(expr->right()); | 3034 VisitForAccumulatorValue(expr->right()); |
3033 builder()->SetExpressionPosition(expr); | 3035 builder()->SetExpressionPosition(expr); |
3034 builder()->CompareOperation(expr->op(), lhs); | 3036 FeedbackVectorSlot slot = expr->CompareOperationFeedbackSlot(); |
| 3037 builder()->CompareOperation(expr->op(), lhs, feedback_index(slot)); |
3035 execution_result()->SetResultInAccumulator(); | 3038 execution_result()->SetResultInAccumulator(); |
3036 } | 3039 } |
3037 | 3040 |
3038 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { | 3041 void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* expr) { |
3039 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for | 3042 // TODO(rmcilroy): Special case "x * 1.0" and "x * -1" which are generated for |
3040 // +x and -x by the parser. | 3043 // +x and -x by the parser. |
3041 Register lhs = VisitForRegisterValue(expr->left()); | 3044 Register lhs = VisitForRegisterValue(expr->left()); |
3042 VisitForAccumulatorValue(expr->right()); | 3045 VisitForAccumulatorValue(expr->right()); |
3043 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); | 3046 FeedbackVectorSlot slot = expr->BinaryOperationFeedbackSlot(); |
3044 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); | 3047 builder()->BinaryOperation(expr->op(), lhs, feedback_index(slot)); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3400 return execution_context()->scope()->language_mode(); | 3403 return execution_context()->scope()->language_mode(); |
3401 } | 3404 } |
3402 | 3405 |
3403 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 3406 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
3404 return TypeFeedbackVector::GetIndex(slot); | 3407 return TypeFeedbackVector::GetIndex(slot); |
3405 } | 3408 } |
3406 | 3409 |
3407 } // namespace interpreter | 3410 } // namespace interpreter |
3408 } // namespace internal | 3411 } // namespace internal |
3409 } // namespace v8 | 3412 } // namespace v8 |
OLD | NEW |