| 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/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
| 10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
| (...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 | 1128 |
| 1129 void BytecodeGraphBuilder::BuildBinaryOp(const Operator* js_op) { | 1129 void BytecodeGraphBuilder::BuildBinaryOp(const Operator* js_op) { |
| 1130 FrameStateBeforeAndAfter states(this); | 1130 FrameStateBeforeAndAfter states(this); |
| 1131 Node* left = | 1131 Node* left = |
| 1132 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); | 1132 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 1133 Node* right = environment()->LookupAccumulator(); | 1133 Node* right = environment()->LookupAccumulator(); |
| 1134 Node* node = NewNode(js_op, left, right); | 1134 Node* node = NewNode(js_op, left, right); |
| 1135 environment()->BindAccumulator(node, &states); | 1135 environment()->BindAccumulator(node, &states); |
| 1136 } | 1136 } |
| 1137 | 1137 |
| 1138 // Helper function to create binary operation hint from the recorded type |
| 1139 // feedback. |
| 1140 BinaryOperationHints BytecodeGraphBuilder::GetBinaryOperationHint() { |
| 1141 FeedbackVectorSlot slot = |
| 1142 feedback_vector()->ToSlot(bytecode_iterator().GetIndexOperand(1)); |
| 1143 DCHECK_EQ(FeedbackVectorSlotKind::GENERAL, feedback_vector()->GetKind(slot)); |
| 1144 Object* feedback = feedback_vector()->Get(slot); |
| 1145 BinaryOperationHints::Hint hint = BinaryOperationHints::Hint::kAny; |
| 1146 if (feedback->IsSmi()) { |
| 1147 hint = BinaryOperationHintFromFeedback((Smi::cast(feedback))->value()); |
| 1148 } |
| 1149 return BinaryOperationHints(hint, hint, hint); |
| 1150 } |
| 1151 |
| 1138 void BytecodeGraphBuilder::VisitAdd() { | 1152 void BytecodeGraphBuilder::VisitAdd() { |
| 1139 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1153 BinaryOperationHints hints = BinaryOperationHints::Any(); |
| 1140 BuildBinaryOp(javascript()->Add(hints)); | 1154 BuildBinaryOp(javascript()->Add(hints)); |
| 1141 } | 1155 } |
| 1142 | 1156 |
| 1143 void BytecodeGraphBuilder::VisitSub() { | 1157 void BytecodeGraphBuilder::VisitSub() { |
| 1144 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1158 BuildBinaryOp(javascript()->Subtract(GetBinaryOperationHint())); |
| 1145 BuildBinaryOp(javascript()->Subtract(hints)); | |
| 1146 } | 1159 } |
| 1147 | 1160 |
| 1148 void BytecodeGraphBuilder::VisitMul() { | 1161 void BytecodeGraphBuilder::VisitMul() { |
| 1149 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1162 BinaryOperationHints hints = BinaryOperationHints::Any(); |
| 1150 BuildBinaryOp(javascript()->Multiply(hints)); | 1163 BuildBinaryOp(javascript()->Multiply(hints)); |
| 1151 } | 1164 } |
| 1152 | 1165 |
| 1153 void BytecodeGraphBuilder::VisitDiv() { | 1166 void BytecodeGraphBuilder::VisitDiv() { |
| 1154 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1167 BinaryOperationHints hints = BinaryOperationHints::Any(); |
| 1155 BuildBinaryOp(javascript()->Divide(hints)); | 1168 BuildBinaryOp(javascript()->Divide(hints)); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 // Phi does not exist yet, introduce one. | 1836 // Phi does not exist yet, introduce one. |
| 1824 value = NewPhi(inputs, value, control); | 1837 value = NewPhi(inputs, value, control); |
| 1825 value->ReplaceInput(inputs - 1, other); | 1838 value->ReplaceInput(inputs - 1, other); |
| 1826 } | 1839 } |
| 1827 return value; | 1840 return value; |
| 1828 } | 1841 } |
| 1829 | 1842 |
| 1830 } // namespace compiler | 1843 } // namespace compiler |
| 1831 } // namespace internal | 1844 } // namespace internal |
| 1832 } // namespace v8 | 1845 } // namespace v8 |
| OLD | NEW |