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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 break; | 641 break; |
642 case IrOpcode::kCheckedInt32Mod: | 642 case IrOpcode::kCheckedInt32Mod: |
643 state = LowerCheckedInt32Mod(node, frame_state, *effect, *control); | 643 state = LowerCheckedInt32Mod(node, frame_state, *effect, *control); |
644 break; | 644 break; |
645 case IrOpcode::kCheckedUint32Div: | 645 case IrOpcode::kCheckedUint32Div: |
646 state = LowerCheckedUint32Div(node, frame_state, *effect, *control); | 646 state = LowerCheckedUint32Div(node, frame_state, *effect, *control); |
647 break; | 647 break; |
648 case IrOpcode::kCheckedUint32Mod: | 648 case IrOpcode::kCheckedUint32Mod: |
649 state = LowerCheckedUint32Mod(node, frame_state, *effect, *control); | 649 state = LowerCheckedUint32Mod(node, frame_state, *effect, *control); |
650 break; | 650 break; |
| 651 case IrOpcode::kCheckedInt32Mul: |
| 652 state = LowerCheckedInt32Mul(node, frame_state, *effect, *control); |
| 653 break; |
651 case IrOpcode::kCheckedUint32ToInt32: | 654 case IrOpcode::kCheckedUint32ToInt32: |
652 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control); | 655 state = LowerCheckedUint32ToInt32(node, frame_state, *effect, *control); |
653 break; | 656 break; |
654 case IrOpcode::kCheckedFloat64ToInt32: | 657 case IrOpcode::kCheckedFloat64ToInt32: |
655 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control); | 658 state = LowerCheckedFloat64ToInt32(node, frame_state, *effect, *control); |
656 break; | 659 break; |
657 case IrOpcode::kCheckedTaggedToInt32: | 660 case IrOpcode::kCheckedTaggedToInt32: |
658 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control); | 661 state = LowerCheckedTaggedToInt32(node, frame_state, *effect, *control); |
659 break; | 662 break; |
660 case IrOpcode::kCheckedTaggedToFloat64: | 663 case IrOpcode::kCheckedTaggedToFloat64: |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check, | 1295 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check, |
1293 frame_state, effect, control); | 1296 frame_state, effect, control); |
1294 | 1297 |
1295 // Perform the actual unsigned integer modulus. | 1298 // Perform the actual unsigned integer modulus. |
1296 Node* value = graph()->NewNode(machine()->Uint32Mod(), lhs, rhs, control); | 1299 Node* value = graph()->NewNode(machine()->Uint32Mod(), lhs, rhs, control); |
1297 | 1300 |
1298 return ValueEffectControl(value, effect, control); | 1301 return ValueEffectControl(value, effect, control); |
1299 } | 1302 } |
1300 | 1303 |
1301 EffectControlLinearizer::ValueEffectControl | 1304 EffectControlLinearizer::ValueEffectControl |
| 1305 EffectControlLinearizer::LowerCheckedInt32Mul(Node* node, Node* frame_state, |
| 1306 Node* effect, Node* control) { |
| 1307 Node* zero = jsgraph()->Int32Constant(0); |
| 1308 Node* lhs = node->InputAt(0); |
| 1309 Node* rhs = node->InputAt(1); |
| 1310 |
| 1311 Node* projection = |
| 1312 graph()->NewNode(machine()->Int32MulWithOverflow(), lhs, rhs, control); |
| 1313 |
| 1314 Node* check = graph()->NewNode(common()->Projection(1), projection, control); |
| 1315 control = effect = graph()->NewNode(common()->DeoptimizeIf(), check, |
| 1316 frame_state, effect, control); |
| 1317 |
| 1318 Node* value = graph()->NewNode(common()->Projection(0), projection, control); |
| 1319 |
| 1320 Node* check_zero = graph()->NewNode(machine()->Word32Equal(), value, zero); |
| 1321 Node* branch_zero = graph()->NewNode(common()->Branch(BranchHint::kFalse), |
| 1322 check_zero, control); |
| 1323 |
| 1324 Node* if_zero = graph()->NewNode(common()->IfTrue(), branch_zero); |
| 1325 Node* e_if_zero = effect; |
| 1326 { |
| 1327 // We may need to return negative zero. |
| 1328 Node* or_inputs = graph()->NewNode(machine()->Word32Or(), lhs, rhs); |
| 1329 Node* check_or = |
| 1330 graph()->NewNode(machine()->Int32LessThan(), or_inputs, zero); |
| 1331 if_zero = e_if_zero = graph()->NewNode(common()->DeoptimizeIf(), check_or, |
| 1332 frame_state, e_if_zero, if_zero); |
| 1333 } |
| 1334 |
| 1335 Node* if_not_zero = graph()->NewNode(common()->IfFalse(), branch_zero); |
| 1336 Node* e_if_not_zero = effect; |
| 1337 |
| 1338 control = graph()->NewNode(common()->Merge(2), if_zero, if_not_zero); |
| 1339 effect = graph()->NewNode(common()->EffectPhi(2), e_if_zero, e_if_not_zero, |
| 1340 control); |
| 1341 |
| 1342 return ValueEffectControl(value, effect, control); |
| 1343 } |
| 1344 |
| 1345 EffectControlLinearizer::ValueEffectControl |
1302 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node, | 1346 EffectControlLinearizer::LowerCheckedUint32ToInt32(Node* node, |
1303 Node* frame_state, | 1347 Node* frame_state, |
1304 Node* effect, | 1348 Node* effect, |
1305 Node* control) { | 1349 Node* control) { |
1306 Node* value = node->InputAt(0); | 1350 Node* value = node->InputAt(0); |
1307 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max()); | 1351 Node* max_int = jsgraph()->Int32Constant(std::numeric_limits<int32_t>::max()); |
1308 Node* is_safe = | 1352 Node* is_safe = |
1309 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int); | 1353 graph()->NewNode(machine()->Uint32LessThanOrEqual(), value, max_int); |
1310 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe, | 1354 control = effect = graph()->NewNode(common()->DeoptimizeUnless(), is_safe, |
1311 frame_state, effect, control); | 1355 frame_state, effect, control); |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2060 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 2104 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
2061 Operator::kNoThrow); | 2105 Operator::kNoThrow); |
2062 to_number_operator_.set(common()->Call(desc)); | 2106 to_number_operator_.set(common()->Call(desc)); |
2063 } | 2107 } |
2064 return to_number_operator_.get(); | 2108 return to_number_operator_.get(); |
2065 } | 2109 } |
2066 | 2110 |
2067 } // namespace compiler | 2111 } // namespace compiler |
2068 } // namespace internal | 2112 } // namespace internal |
2069 } // namespace v8 | 2113 } // namespace v8 |
OLD | NEW |