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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 BuildBinaryOp(javascript()->ShiftRight(hints)); | 1114 BuildBinaryOp(javascript()->ShiftRight(hints)); |
1115 } | 1115 } |
1116 | 1116 |
1117 void BytecodeGraphBuilder::VisitShiftRightLogical() { | 1117 void BytecodeGraphBuilder::VisitShiftRightLogical() { |
1118 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1118 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1119 BuildBinaryOp(javascript()->ShiftRightLogical(hints)); | 1119 BuildBinaryOp(javascript()->ShiftRightLogical(hints)); |
1120 } | 1120 } |
1121 | 1121 |
1122 void BytecodeGraphBuilder::VisitInc() { | 1122 void BytecodeGraphBuilder::VisitInc() { |
1123 FrameStateBeforeAndAfter states(this); | 1123 FrameStateBeforeAndAfter states(this); |
1124 const Operator* js_op = javascript()->Add(BinaryOperationHints::Any()); | 1124 // Note: Use subtract -1 here instead of add 1 to ensure we always convert to |
| 1125 // a number, not a string. |
| 1126 const Operator* js_op = javascript()->Subtract(BinaryOperationHints::Any()); |
1125 Node* node = NewNode(js_op, environment()->LookupAccumulator(), | 1127 Node* node = NewNode(js_op, environment()->LookupAccumulator(), |
1126 jsgraph()->OneConstant()); | 1128 jsgraph()->Constant(-1.0)); |
1127 environment()->BindAccumulator(node, &states); | 1129 environment()->BindAccumulator(node, &states); |
1128 } | 1130 } |
1129 | 1131 |
1130 void BytecodeGraphBuilder::VisitDec() { | 1132 void BytecodeGraphBuilder::VisitDec() { |
1131 FrameStateBeforeAndAfter states(this); | 1133 FrameStateBeforeAndAfter states(this); |
1132 const Operator* js_op = javascript()->Subtract(BinaryOperationHints::Any()); | 1134 const Operator* js_op = javascript()->Subtract(BinaryOperationHints::Any()); |
1133 Node* node = NewNode(js_op, environment()->LookupAccumulator(), | 1135 Node* node = NewNode(js_op, environment()->LookupAccumulator(), |
1134 jsgraph()->OneConstant()); | 1136 jsgraph()->OneConstant()); |
1135 environment()->BindAccumulator(node, &states); | 1137 environment()->BindAccumulator(node, &states); |
1136 } | 1138 } |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 // Phi does not exist yet, introduce one. | 1644 // Phi does not exist yet, introduce one. |
1643 value = NewPhi(inputs, value, control); | 1645 value = NewPhi(inputs, value, control); |
1644 value->ReplaceInput(inputs - 1, other); | 1646 value->ReplaceInput(inputs - 1, other); |
1645 } | 1647 } |
1646 return value; | 1648 return value; |
1647 } | 1649 } |
1648 | 1650 |
1649 } // namespace compiler | 1651 } // namespace compiler |
1650 } // namespace internal | 1652 } // namespace internal |
1651 } // namespace v8 | 1653 } // namespace v8 |
OLD | NEW |