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/compiler/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // => unsigned Uint32Mod | 682 // => unsigned Uint32Mod |
683 VisitUint32Binop(node); | 683 VisitUint32Binop(node); |
684 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); | 684 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node)); |
685 break; | 685 break; |
686 } | 686 } |
687 // => Float64Mod | 687 // => Float64Mod |
688 VisitFloat64Binop(node); | 688 VisitFloat64Binop(node); |
689 if (lower()) node->set_op(Float64Op(node)); | 689 if (lower()) node->set_op(Float64Op(node)); |
690 break; | 690 break; |
691 } | 691 } |
| 692 case IrOpcode::kNumberShiftLeft: { |
| 693 VisitBinop(node, kMachInt32, kMachUint32, kMachInt32); |
| 694 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shl()); |
| 695 break; |
| 696 } |
| 697 case IrOpcode::kNumberShiftRight: { |
| 698 VisitBinop(node, kMachInt32, kMachUint32, kMachInt32); |
| 699 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Sar()); |
| 700 break; |
| 701 } |
| 702 case IrOpcode::kNumberShiftRightLogical: { |
| 703 VisitBinop(node, kMachUint32, kMachUint32, kMachUint32); |
| 704 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); |
| 705 break; |
| 706 } |
692 case IrOpcode::kNumberToInt32: { | 707 case IrOpcode::kNumberToInt32: { |
693 MachineTypeUnion use_rep = use & kRepMask; | 708 MachineTypeUnion use_rep = use & kRepMask; |
694 Node* input = node->InputAt(0); | 709 Node* input = node->InputAt(0); |
695 Type* in_upper = NodeProperties::GetBounds(input).upper; | 710 Type* in_upper = NodeProperties::GetBounds(input).upper; |
696 MachineTypeUnion in = GetInfo(input)->output; | 711 MachineTypeUnion in = GetInfo(input)->output; |
697 if (in_upper->Is(Type::Signed32())) { | 712 if (in_upper->Is(Type::Signed32())) { |
698 // If the input has type int32, pass through representation. | 713 // If the input has type int32, pass through representation. |
699 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); | 714 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); |
700 if (lower()) DeferReplacement(node, node->InputAt(0)); | 715 if (lower()) DeferReplacement(node, node->InputAt(0)); |
701 } else if ((in & kTypeMask) == kTypeUint32 || | 716 } else if ((in & kTypeMask) == kTypeUint32 || |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 | 1126 |
1112 | 1127 |
1113 Node* SimplifiedLowering::IsTagged(Node* node) { | 1128 Node* SimplifiedLowering::IsTagged(Node* node) { |
1114 // TODO(titzer): factor this out to a TaggingScheme abstraction. | 1129 // TODO(titzer): factor this out to a TaggingScheme abstraction. |
1115 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. | 1130 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. |
1116 return graph()->NewNode(machine()->WordAnd(), node, | 1131 return graph()->NewNode(machine()->WordAnd(), node, |
1117 jsgraph()->Int32Constant(kSmiTagMask)); | 1132 jsgraph()->Int32Constant(kSmiTagMask)); |
1118 } | 1133 } |
1119 | 1134 |
1120 | 1135 |
| 1136 SimplifiedLowering::SimplifiedLowering(JSGraph* jsgraph, Zone* zone, |
| 1137 SourcePositionTable* source_positions) |
| 1138 : jsgraph_(jsgraph), |
| 1139 zone_(zone), |
| 1140 zero_thirtyone_range_(Type::Range(0, 31, zone)), |
| 1141 source_positions_(source_positions) {} |
| 1142 |
| 1143 |
1121 void SimplifiedLowering::LowerAllNodes() { | 1144 void SimplifiedLowering::LowerAllNodes() { |
1122 SimplifiedOperatorBuilder simplified(graph()->zone()); | 1145 SimplifiedOperatorBuilder simplified(graph()->zone()); |
1123 RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate()); | 1146 RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate()); |
1124 RepresentationSelector selector(jsgraph(), zone_, &changer, | 1147 RepresentationSelector selector(jsgraph(), zone_, &changer, |
1125 source_positions_); | 1148 source_positions_); |
1126 selector.Run(this); | 1149 selector.Run(this); |
1127 } | 1150 } |
1128 | 1151 |
1129 | 1152 |
1130 Node* SimplifiedLowering::Untag(Node* node) { | 1153 Node* SimplifiedLowering::Untag(Node* node) { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 } | 1592 } |
1570 | 1593 |
1571 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0); | 1594 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0); |
1572 Node* false0 = zero; | 1595 Node* false0 = zero; |
1573 | 1596 |
1574 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0); | 1597 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0); |
1575 return graph()->NewNode(phi_op, true0, false0, merge0); | 1598 return graph()->NewNode(phi_op, true0, false0, merge0); |
1576 } | 1599 } |
1577 | 1600 |
1578 | 1601 |
| 1602 void SimplifiedLowering::DoShift(Node* node, Operator const* op) { |
| 1603 node->set_op(op); |
| 1604 Node* const rhs = NodeProperties::GetValueInput(node, 1); |
| 1605 Type* const rhs_type = NodeProperties::GetBounds(rhs).upper; |
| 1606 if (!rhs_type->Is(zero_thirtyone_range_)) { |
| 1607 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs, |
| 1608 jsgraph()->Int32Constant(0x1f))); |
| 1609 } |
| 1610 } |
| 1611 |
| 1612 |
1579 void SimplifiedLowering::DoStringEqual(Node* node) { | 1613 void SimplifiedLowering::DoStringEqual(Node* node) { |
1580 node->set_op(machine()->WordEqual()); | 1614 node->set_op(machine()->WordEqual()); |
1581 node->ReplaceInput(0, StringComparison(node, false)); | 1615 node->ReplaceInput(0, StringComparison(node, false)); |
1582 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1616 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1583 } | 1617 } |
1584 | 1618 |
1585 | 1619 |
1586 void SimplifiedLowering::DoStringLessThan(Node* node) { | 1620 void SimplifiedLowering::DoStringLessThan(Node* node) { |
1587 node->set_op(machine()->IntLessThan()); | 1621 node->set_op(machine()->IntLessThan()); |
1588 node->ReplaceInput(0, StringComparison(node, true)); | 1622 node->ReplaceInput(0, StringComparison(node, true)); |
1589 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1623 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1590 } | 1624 } |
1591 | 1625 |
1592 | 1626 |
1593 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1627 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1594 node->set_op(machine()->IntLessThanOrEqual()); | 1628 node->set_op(machine()->IntLessThanOrEqual()); |
1595 node->ReplaceInput(0, StringComparison(node, true)); | 1629 node->ReplaceInput(0, StringComparison(node, true)); |
1596 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1630 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1597 } | 1631 } |
1598 | 1632 |
1599 } // namespace compiler | 1633 } // namespace compiler |
1600 } // namespace internal | 1634 } // namespace internal |
1601 } // namespace v8 | 1635 } // namespace v8 |
OLD | NEW |