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 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 | 1356 |
1357 Node* SimplifiedLowering::StringComparison(Node* node) { | 1357 Node* SimplifiedLowering::StringComparison(Node* node) { |
1358 Operator::Properties properties = node->op()->properties(); | 1358 Operator::Properties properties = node->op()->properties(); |
1359 Callable callable = CodeFactory::StringCompare(isolate()); | 1359 Callable callable = CodeFactory::StringCompare(isolate()); |
1360 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 1360 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
1361 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | 1361 CallDescriptor* desc = Linkage::GetStubCallDescriptor( |
1362 isolate(), zone(), callable.descriptor(), 0, flags, properties); | 1362 isolate(), zone(), callable.descriptor(), 0, flags, properties); |
1363 return graph()->NewNode( | 1363 return graph()->NewNode( |
1364 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), | 1364 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), |
1365 NodeProperties::GetValueInput(node, 0), | 1365 NodeProperties::GetValueInput(node, 0), |
1366 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant()); | 1366 NodeProperties::GetValueInput(node, 1), jsgraph()->NoContextConstant(), |
| 1367 NodeProperties::GetEffectInput(node), |
| 1368 NodeProperties::GetControlInput(node)); |
1367 } | 1369 } |
1368 | 1370 |
1369 | 1371 |
1370 Node* SimplifiedLowering::Int32Div(Node* const node) { | 1372 Node* SimplifiedLowering::Int32Div(Node* const node) { |
1371 Int32BinopMatcher m(node); | 1373 Int32BinopMatcher m(node); |
1372 Node* const zero = jsgraph()->Int32Constant(0); | 1374 Node* const zero = jsgraph()->Int32Constant(0); |
1373 Node* const minus_one = jsgraph()->Int32Constant(-1); | 1375 Node* const minus_one = jsgraph()->Int32Constant(-1); |
1374 Node* const lhs = m.left().node(); | 1376 Node* const lhs = m.left().node(); |
1375 Node* const rhs = m.right().node(); | 1377 Node* const rhs = m.right().node(); |
1376 | 1378 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1620 Node* const rhs = NodeProperties::GetValueInput(node, 1); | 1622 Node* const rhs = NodeProperties::GetValueInput(node, 1); |
1621 Type* const rhs_type = NodeProperties::GetType(rhs); | 1623 Type* const rhs_type = NodeProperties::GetType(rhs); |
1622 if (!rhs_type->Is(zero_thirtyone_range_)) { | 1624 if (!rhs_type->Is(zero_thirtyone_range_)) { |
1623 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs, | 1625 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs, |
1624 jsgraph()->Int32Constant(0x1f))); | 1626 jsgraph()->Int32Constant(0x1f))); |
1625 } | 1627 } |
1626 NodeProperties::ChangeOp(node, op); | 1628 NodeProperties::ChangeOp(node, op); |
1627 } | 1629 } |
1628 | 1630 |
1629 | 1631 |
| 1632 namespace { |
| 1633 |
| 1634 void ReplaceEffectUses(Node* node, Node* replacement) { |
| 1635 // Requires distinguishing between value and effect edges. |
| 1636 DCHECK(replacement->op()->EffectOutputCount() > 0); |
| 1637 for (Edge edge : node->use_edges()) { |
| 1638 if (NodeProperties::IsEffectEdge(edge)) { |
| 1639 edge.UpdateTo(replacement); |
| 1640 } else { |
| 1641 DCHECK(NodeProperties::IsValueEdge(edge)); |
| 1642 } |
| 1643 } |
| 1644 } |
| 1645 |
| 1646 } // namespace |
| 1647 |
| 1648 |
1630 void SimplifiedLowering::DoStringEqual(Node* node) { | 1649 void SimplifiedLowering::DoStringEqual(Node* node) { |
1631 node->ReplaceInput(0, StringComparison(node)); | 1650 Node* comparison = StringComparison(node); |
| 1651 ReplaceEffectUses(node, comparison); |
| 1652 node->ReplaceInput(0, comparison); |
1632 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1653 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1654 node->TrimInputCount(2); |
1633 NodeProperties::ChangeOp(node, machine()->WordEqual()); | 1655 NodeProperties::ChangeOp(node, machine()->WordEqual()); |
1634 } | 1656 } |
1635 | 1657 |
1636 | 1658 |
1637 void SimplifiedLowering::DoStringLessThan(Node* node) { | 1659 void SimplifiedLowering::DoStringLessThan(Node* node) { |
1638 node->ReplaceInput(0, StringComparison(node)); | 1660 Node* comparison = StringComparison(node); |
| 1661 ReplaceEffectUses(node, comparison); |
| 1662 node->ReplaceInput(0, comparison); |
1639 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1663 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1664 node->TrimInputCount(2); |
1640 NodeProperties::ChangeOp(node, machine()->IntLessThan()); | 1665 NodeProperties::ChangeOp(node, machine()->IntLessThan()); |
1641 } | 1666 } |
1642 | 1667 |
1643 | 1668 |
1644 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1669 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1645 node->ReplaceInput(0, StringComparison(node)); | 1670 Node* comparison = StringComparison(node); |
| 1671 ReplaceEffectUses(node, comparison); |
| 1672 node->ReplaceInput(0, comparison); |
1646 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1673 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
| 1674 node->TrimInputCount(2); |
1647 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1675 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1648 } | 1676 } |
1649 | 1677 |
1650 } // namespace compiler | 1678 } // namespace compiler |
1651 } // namespace internal | 1679 } // namespace internal |
1652 } // namespace v8 | 1680 } // namespace v8 |
OLD | NEW |