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/address-map.h" | 9 #include "src/address-map.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 } | 1685 } |
1686 case IrOpcode::kNumberShiftRight: { | 1686 case IrOpcode::kNumberShiftRight: { |
1687 Type* rhs_type = GetUpperBound(node->InputAt(1)); | 1687 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
1688 VisitBinop(node, UseInfo::TruncatingWord32(), | 1688 VisitBinop(node, UseInfo::TruncatingWord32(), |
1689 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); | 1689 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); |
1690 if (lower()) { | 1690 if (lower()) { |
1691 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); | 1691 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); |
1692 } | 1692 } |
1693 return; | 1693 return; |
1694 } | 1694 } |
| 1695 case IrOpcode::kSpeculativeNumberShiftRight: { |
| 1696 // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we |
| 1697 // can only eliminate an unused speculative number operation if we know |
| 1698 // that the inputs are PlainPrimitive, which excludes everything that's |
| 1699 // might have side effects or throws during a ToNumber conversion. |
| 1700 if (BothInputsAre(node, Type::PlainPrimitive())) { |
| 1701 if (truncation.IsUnused()) return VisitUnused(node); |
| 1702 } |
| 1703 if (BothInputsAre(node, Type::NumberOrOddball())) { |
| 1704 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
| 1705 VisitBinop(node, UseInfo::TruncatingWord32(), |
| 1706 UseInfo::TruncatingWord32(), |
| 1707 MachineRepresentation::kWord32); |
| 1708 if (lower()) { |
| 1709 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); |
| 1710 } |
| 1711 return; |
| 1712 } |
| 1713 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
| 1714 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
| 1715 VisitBinop(node, hint == BinaryOperationHints::kNumberOrOddball |
| 1716 ? UseInfo::CheckedNumberOrOddballAsWord32() |
| 1717 : UseInfo::CheckedSigned32AsWord32(), |
| 1718 MachineRepresentation::kWord32, Type::Signed32()); |
| 1719 if (lower()) { |
| 1720 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type); |
| 1721 } |
| 1722 return; |
| 1723 } |
1695 case IrOpcode::kNumberShiftRightLogical: { | 1724 case IrOpcode::kNumberShiftRightLogical: { |
1696 Type* rhs_type = GetUpperBound(node->InputAt(1)); | 1725 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
1697 VisitBinop(node, UseInfo::TruncatingWord32(), | 1726 VisitBinop(node, UseInfo::TruncatingWord32(), |
1698 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); | 1727 UseInfo::TruncatingWord32(), MachineRepresentation::kWord32); |
1699 if (lower()) { | 1728 if (lower()) { |
1700 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); | 1729 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
1701 } | 1730 } |
1702 return; | 1731 return; |
1703 } | 1732 } |
| 1733 case IrOpcode::kSpeculativeNumberShiftRightLogical: { |
| 1734 // ToNumber(x) can throw if x is either a Receiver or a Symbol, so we |
| 1735 // can only eliminate an unused speculative number operation if we know |
| 1736 // that the inputs are PlainPrimitive, which excludes everything that's |
| 1737 // might have side effects or throws during a ToNumber conversion. |
| 1738 if (BothInputsAre(node, Type::PlainPrimitive())) { |
| 1739 if (truncation.IsUnused()) return VisitUnused(node); |
| 1740 } |
| 1741 if (BothInputsAre(node, Type::NumberOrOddball())) { |
| 1742 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
| 1743 VisitBinop(node, UseInfo::TruncatingWord32(), |
| 1744 UseInfo::TruncatingWord32(), |
| 1745 MachineRepresentation::kWord32); |
| 1746 if (lower()) { |
| 1747 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
| 1748 } |
| 1749 return; |
| 1750 } |
| 1751 BinaryOperationHints::Hint hint = BinaryOperationHintOf(node->op()); |
| 1752 Type* rhs_type = GetUpperBound(node->InputAt(1)); |
| 1753 VisitBinop(node, hint == BinaryOperationHints::kNumberOrOddball |
| 1754 ? UseInfo::CheckedNumberOrOddballAsWord32() |
| 1755 : UseInfo::CheckedSigned32AsWord32(), |
| 1756 MachineRepresentation::kWord32, Type::Unsigned32()); |
| 1757 if (lower()) { |
| 1758 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type); |
| 1759 } |
| 1760 return; |
| 1761 } |
1704 case IrOpcode::kNumberAbs: { | 1762 case IrOpcode::kNumberAbs: { |
1705 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { | 1763 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) { |
1706 VisitUnop(node, UseInfo::TruncatingWord32(), | 1764 VisitUnop(node, UseInfo::TruncatingWord32(), |
1707 MachineRepresentation::kWord32); | 1765 MachineRepresentation::kWord32); |
1708 if (lower()) DeferReplacement(node, node->InputAt(0)); | 1766 if (lower()) DeferReplacement(node, node->InputAt(0)); |
1709 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32())) { | 1767 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32())) { |
1710 VisitUnop(node, UseInfo::TruncatingWord32(), | 1768 VisitUnop(node, UseInfo::TruncatingWord32(), |
1711 MachineRepresentation::kWord32); | 1769 MachineRepresentation::kWord32); |
1712 if (lower()) DeferReplacement(node, lowering->Int32Abs(node)); | 1770 if (lower()) DeferReplacement(node, lowering->Int32Abs(node)); |
1713 } else if (TypeOf(node->InputAt(0)) | 1771 } else if (TypeOf(node->InputAt(0)) |
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3513 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3571 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3514 Operator::kNoProperties); | 3572 Operator::kNoProperties); |
3515 to_number_operator_.set(common()->Call(desc)); | 3573 to_number_operator_.set(common()->Call(desc)); |
3516 } | 3574 } |
3517 return to_number_operator_.get(); | 3575 return to_number_operator_.get(); |
3518 } | 3576 } |
3519 | 3577 |
3520 } // namespace compiler | 3578 } // namespace compiler |
3521 } // namespace internal | 3579 } // namespace internal |
3522 } // namespace v8 | 3580 } // namespace v8 |
OLD | NEW |