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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 664 |
665 void ResetOutput(Node* node, MachineRepresentation representation, | 665 void ResetOutput(Node* node, MachineRepresentation representation, |
666 TypeCheckKind type_check = TypeCheckKind::kNone) { | 666 TypeCheckKind type_check = TypeCheckKind::kNone) { |
667 NodeInfo* info = GetInfo(node); | 667 NodeInfo* info = GetInfo(node); |
668 info->set_output(representation); | 668 info->set_output(representation); |
669 info->set_type_check(type_check); | 669 info->set_type_check(type_check); |
670 } | 670 } |
671 | 671 |
672 Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); } | 672 Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); } |
673 | 673 |
| 674 bool InputCannotBe(Node* node, Type* type) { |
| 675 DCHECK_EQ(1, node->op()->ValueInputCount()); |
| 676 return !GetUpperBound(node->InputAt(0))->Maybe(type); |
| 677 } |
| 678 |
674 bool InputIs(Node* node, Type* type) { | 679 bool InputIs(Node* node, Type* type) { |
675 DCHECK_EQ(1, node->op()->ValueInputCount()); | 680 DCHECK_EQ(1, node->op()->ValueInputCount()); |
676 return GetUpperBound(node->InputAt(0))->Is(type); | 681 return GetUpperBound(node->InputAt(0))->Is(type); |
677 } | 682 } |
678 | 683 |
679 bool BothInputsAreSigned32(Node* node) { | 684 bool BothInputsAreSigned32(Node* node) { |
680 return BothInputsAre(node, Type::Signed32()); | 685 return BothInputsAre(node, Type::Signed32()); |
681 } | 686 } |
682 | 687 |
683 bool BothInputsAreUnsigned32(Node* node) { | 688 bool BothInputsAreUnsigned32(Node* node) { |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 VisitUnop(node, UseInfo::TruncatingFloat64(), | 1701 VisitUnop(node, UseInfo::TruncatingFloat64(), |
1697 MachineRepresentation::kFloat64); | 1702 MachineRepresentation::kFloat64); |
1698 } | 1703 } |
1699 if (lower()) DeferReplacement(node, node->InputAt(0)); | 1704 if (lower()) DeferReplacement(node, node->InputAt(0)); |
1700 } else { | 1705 } else { |
1701 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 1706 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
1702 } | 1707 } |
1703 return; | 1708 return; |
1704 } | 1709 } |
1705 case IrOpcode::kCheckTaggedPointer: { | 1710 case IrOpcode::kCheckTaggedPointer: { |
1706 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 1711 if (InputCannotBe(node, Type::SignedSmall())) { |
1707 if (lower()) { | 1712 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
1708 if (InputIs(node, Type::TaggedPointer())) { | 1713 if (lower()) DeferReplacement(node, node->InputAt(0)); |
1709 DeferReplacement(node, node->InputAt(0)); | 1714 } else { |
1710 } | 1715 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
1711 } | 1716 } |
1712 return; | 1717 return; |
1713 } | 1718 } |
1714 case IrOpcode::kCheckTaggedSigned: { | 1719 case IrOpcode::kCheckTaggedSigned: { |
1715 if (SmiValuesAre32Bits() && truncation.TruncatesToWord32()) { | 1720 if (SmiValuesAre32Bits() && truncation.TruncatesToWord32()) { |
1716 // TODO(jarin,bmeurer): Add CheckedSignedSmallAsWord32? | 1721 // TODO(jarin,bmeurer): Add CheckedSignedSmallAsWord32? |
1717 VisitUnop(node, UseInfo::CheckedSigned32AsWord32(), | 1722 VisitUnop(node, UseInfo::CheckedSigned32AsWord32(), |
1718 MachineRepresentation::kWord32); | 1723 MachineRepresentation::kWord32); |
1719 if (lower()) DeferReplacement(node, node->InputAt(0)); | 1724 if (lower()) DeferReplacement(node, node->InputAt(0)); |
1720 } else { | 1725 } else { |
1721 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); | 1726 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); |
1722 if (lower()) { | |
1723 if (InputIs(node, Type::TaggedSigned())) { | |
1724 DeferReplacement(node, node->InputAt(0)); | |
1725 } | |
1726 } | |
1727 } | 1727 } |
1728 return; | 1728 return; |
1729 } | 1729 } |
1730 | 1730 |
1731 case IrOpcode::kAllocate: { | 1731 case IrOpcode::kAllocate: { |
1732 ProcessInput(node, 0, UseInfo::TruncatingWord32()); | 1732 ProcessInput(node, 0, UseInfo::TruncatingWord32()); |
1733 ProcessRemainingInputs(node, 1); | 1733 ProcessRemainingInputs(node, 1); |
1734 SetOutput(node, MachineRepresentation::kTagged); | 1734 SetOutput(node, MachineRepresentation::kTagged); |
1735 return; | 1735 return; |
1736 } | 1736 } |
1737 case IrOpcode::kLoadField: { | 1737 case IrOpcode::kLoadField: { |
1738 FieldAccess access = FieldAccessOf(node->op()); | 1738 FieldAccess access = FieldAccessOf(node->op()); |
1739 ProcessInput(node, 0, UseInfoForBasePointer(access)); | 1739 ProcessInput(node, 0, UseInfoForBasePointer(access)); |
1740 ProcessRemainingInputs(node, 1); | 1740 ProcessRemainingInputs(node, 1); |
1741 SetOutput(node, access.machine_type.representation()); | 1741 SetOutput(node, access.machine_type.representation()); |
1742 return; | 1742 return; |
1743 } | 1743 } |
1744 case IrOpcode::kStoreField: { | 1744 case IrOpcode::kStoreField: { |
1745 FieldAccess access = FieldAccessOf(node->op()); | 1745 FieldAccess access = FieldAccessOf(node->op()); |
| 1746 WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( |
| 1747 access.base_is_tagged, access.machine_type.representation(), |
| 1748 access.offset, access.type, node->InputAt(1)); |
1746 ProcessInput(node, 0, UseInfoForBasePointer(access)); | 1749 ProcessInput(node, 0, UseInfoForBasePointer(access)); |
1747 ProcessInput(node, 1, TruncatingUseInfoFromRepresentation( | 1750 ProcessInput(node, 1, TruncatingUseInfoFromRepresentation( |
1748 access.machine_type.representation())); | 1751 access.machine_type.representation())); |
1749 ProcessRemainingInputs(node, 2); | 1752 ProcessRemainingInputs(node, 2); |
1750 SetOutput(node, MachineRepresentation::kNone); | 1753 SetOutput(node, MachineRepresentation::kNone); |
1751 if (lower()) { | 1754 if (lower()) { |
1752 WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( | |
1753 access.base_is_tagged, access.machine_type.representation(), | |
1754 access.offset, access.type, node->InputAt(1)); | |
1755 if (write_barrier_kind < access.write_barrier_kind) { | 1755 if (write_barrier_kind < access.write_barrier_kind) { |
1756 access.write_barrier_kind = write_barrier_kind; | 1756 access.write_barrier_kind = write_barrier_kind; |
1757 NodeProperties::ChangeOp( | 1757 NodeProperties::ChangeOp( |
1758 node, jsgraph_->simplified()->StoreField(access)); | 1758 node, jsgraph_->simplified()->StoreField(access)); |
1759 } | 1759 } |
1760 } | 1760 } |
1761 return; | 1761 return; |
1762 } | 1762 } |
1763 case IrOpcode::kLoadBuffer: { | 1763 case IrOpcode::kLoadBuffer: { |
1764 BufferAccess access = BufferAccessOf(node->op()); | 1764 BufferAccess access = BufferAccessOf(node->op()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 case IrOpcode::kLoadElement: { | 1809 case IrOpcode::kLoadElement: { |
1810 ElementAccess access = ElementAccessOf(node->op()); | 1810 ElementAccess access = ElementAccessOf(node->op()); |
1811 ProcessInput(node, 0, UseInfoForBasePointer(access)); // base | 1811 ProcessInput(node, 0, UseInfoForBasePointer(access)); // base |
1812 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index | 1812 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index |
1813 ProcessRemainingInputs(node, 2); | 1813 ProcessRemainingInputs(node, 2); |
1814 SetOutput(node, access.machine_type.representation()); | 1814 SetOutput(node, access.machine_type.representation()); |
1815 return; | 1815 return; |
1816 } | 1816 } |
1817 case IrOpcode::kStoreElement: { | 1817 case IrOpcode::kStoreElement: { |
1818 ElementAccess access = ElementAccessOf(node->op()); | 1818 ElementAccess access = ElementAccessOf(node->op()); |
| 1819 WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( |
| 1820 access.base_is_tagged, access.machine_type.representation(), |
| 1821 access.type, node->InputAt(2)); |
1819 ProcessInput(node, 0, UseInfoForBasePointer(access)); // base | 1822 ProcessInput(node, 0, UseInfoForBasePointer(access)); // base |
1820 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index | 1823 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index |
1821 ProcessInput(node, 2, | 1824 ProcessInput(node, 2, |
1822 TruncatingUseInfoFromRepresentation( | 1825 TruncatingUseInfoFromRepresentation( |
1823 access.machine_type.representation())); // value | 1826 access.machine_type.representation())); // value |
1824 ProcessRemainingInputs(node, 3); | 1827 ProcessRemainingInputs(node, 3); |
1825 SetOutput(node, MachineRepresentation::kNone); | 1828 SetOutput(node, MachineRepresentation::kNone); |
1826 if (lower()) { | 1829 if (lower()) { |
1827 WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( | |
1828 access.base_is_tagged, access.machine_type.representation(), | |
1829 access.type, node->InputAt(2)); | |
1830 if (write_barrier_kind < access.write_barrier_kind) { | 1830 if (write_barrier_kind < access.write_barrier_kind) { |
1831 access.write_barrier_kind = write_barrier_kind; | 1831 access.write_barrier_kind = write_barrier_kind; |
1832 NodeProperties::ChangeOp( | 1832 NodeProperties::ChangeOp( |
1833 node, jsgraph_->simplified()->StoreElement(access)); | 1833 node, jsgraph_->simplified()->StoreElement(access)); |
1834 } | 1834 } |
1835 } | 1835 } |
1836 return; | 1836 return; |
1837 } | 1837 } |
1838 case IrOpcode::kPlainPrimitiveToNumber: | 1838 case IrOpcode::kPlainPrimitiveToNumber: |
1839 if (truncation.TruncatesToWord32()) { | 1839 if (truncation.TruncatesToWord32()) { |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3108 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3108 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3109 Operator::kNoProperties); | 3109 Operator::kNoProperties); |
3110 to_number_operator_.set(common()->Call(desc)); | 3110 to_number_operator_.set(common()->Call(desc)); |
3111 } | 3111 } |
3112 return to_number_operator_.get(); | 3112 return to_number_operator_.get(); |
3113 } | 3113 } |
3114 | 3114 |
3115 } // namespace compiler | 3115 } // namespace compiler |
3116 } // namespace internal | 3116 } // namespace internal |
3117 } // namespace v8 | 3117 } // namespace v8 |
OLD | NEW |