OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1); | 381 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node) + 1); |
382 node->InsertInput(graph()->zone(), 0, | 382 node->InsertInput(graph()->zone(), 0, |
383 jsgraph()->HeapConstant(callable.code())); | 383 jsgraph()->HeapConstant(callable.code())); |
384 node->set_op(common()->Call(desc)); | 384 node->set_op(common()->Call(desc)); |
385 return Changed(node); | 385 return Changed(node); |
386 } | 386 } |
387 return NoChange(); | 387 return NoChange(); |
388 } | 388 } |
389 | 389 |
390 | 390 |
| 391 Reduction JSTypedLowering::ReduceJSModulus(Node* node) { |
| 392 JSBinopReduction r(this, node); |
| 393 if (r.BothInputsAre(Type::Number())) { |
| 394 // JSModulus(x:number, x:number) => NumberModulus(x, y) |
| 395 return r.ChangeToPureOperator(simplified()->NumberModulus(), |
| 396 Type::Number()); |
| 397 } |
| 398 return NoChange(); |
| 399 } |
| 400 |
| 401 |
391 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, | 402 Reduction JSTypedLowering::ReduceNumberBinop(Node* node, |
392 const Operator* numberOp) { | 403 const Operator* numberOp) { |
393 JSBinopReduction r(this, node); | 404 JSBinopReduction r(this, node); |
394 if (r.IsStrong()) { | 405 if (r.IsStrong() || numberOp == simplified()->NumberModulus()) { |
395 if (r.BothInputsAre(Type::Number())) { | 406 if (r.BothInputsAre(Type::Number())) { |
396 return r.ChangeToPureOperator(numberOp, Type::Number()); | 407 return r.ChangeToPureOperator(numberOp, Type::Number()); |
397 } | 408 } |
398 return NoChange(); | 409 return NoChange(); |
399 } | 410 } |
400 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); | 411 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); |
401 r.ConvertInputsToNumber(frame_state); | 412 r.ConvertInputsToNumber(frame_state); |
402 return r.ChangeToPureOperator(numberOp, Type::Number()); | 413 return r.ChangeToPureOperator(numberOp, Type::Number()); |
403 } | 414 } |
404 | 415 |
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 return ReduceUI32Shift(node, kUnsigned, machine()->Word32Shr()); | 1473 return ReduceUI32Shift(node, kUnsigned, machine()->Word32Shr()); |
1463 case IrOpcode::kJSAdd: | 1474 case IrOpcode::kJSAdd: |
1464 return ReduceJSAdd(node); | 1475 return ReduceJSAdd(node); |
1465 case IrOpcode::kJSSubtract: | 1476 case IrOpcode::kJSSubtract: |
1466 return ReduceNumberBinop(node, simplified()->NumberSubtract()); | 1477 return ReduceNumberBinop(node, simplified()->NumberSubtract()); |
1467 case IrOpcode::kJSMultiply: | 1478 case IrOpcode::kJSMultiply: |
1468 return ReduceNumberBinop(node, simplified()->NumberMultiply()); | 1479 return ReduceNumberBinop(node, simplified()->NumberMultiply()); |
1469 case IrOpcode::kJSDivide: | 1480 case IrOpcode::kJSDivide: |
1470 return ReduceNumberBinop(node, simplified()->NumberDivide()); | 1481 return ReduceNumberBinop(node, simplified()->NumberDivide()); |
1471 case IrOpcode::kJSModulus: | 1482 case IrOpcode::kJSModulus: |
1472 return ReduceNumberBinop(node, simplified()->NumberModulus()); | 1483 return ReduceJSModulus(node); |
1473 case IrOpcode::kJSUnaryNot: | 1484 case IrOpcode::kJSUnaryNot: |
1474 return ReduceJSUnaryNot(node); | 1485 return ReduceJSUnaryNot(node); |
1475 case IrOpcode::kJSToBoolean: | 1486 case IrOpcode::kJSToBoolean: |
1476 return ReduceJSToBoolean(node); | 1487 return ReduceJSToBoolean(node); |
1477 case IrOpcode::kJSToNumber: | 1488 case IrOpcode::kJSToNumber: |
1478 return ReduceJSToNumber(node); | 1489 return ReduceJSToNumber(node); |
1479 case IrOpcode::kJSToString: | 1490 case IrOpcode::kJSToString: |
1480 return ReduceJSToString(node); | 1491 return ReduceJSToString(node); |
1481 case IrOpcode::kJSLoadNamed: | 1492 case IrOpcode::kJSLoadNamed: |
1482 return ReduceJSLoadNamed(node); | 1493 return ReduceJSLoadNamed(node); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 } | 1552 } |
1542 | 1553 |
1543 | 1554 |
1544 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1555 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1545 return jsgraph()->machine(); | 1556 return jsgraph()->machine(); |
1546 } | 1557 } |
1547 | 1558 |
1548 } // namespace compiler | 1559 } // namespace compiler |
1549 } // namespace internal | 1560 } // namespace internal |
1550 } // namespace v8 | 1561 } // namespace v8 |
OLD | NEW |