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 "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph-inl.h" | 10 #include "src/compiler/graph-inl.h" |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 Node* SimplifiedLowering::IsTagged(Node* node) { | 757 Node* SimplifiedLowering::IsTagged(Node* node) { |
758 // TODO(titzer): factor this out to a TaggingScheme abstraction. | 758 // TODO(titzer): factor this out to a TaggingScheme abstraction. |
759 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. | 759 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. |
760 return graph()->NewNode(machine()->WordAnd(), node, | 760 return graph()->NewNode(machine()->WordAnd(), node, |
761 jsgraph()->Int32Constant(kSmiTagMask)); | 761 jsgraph()->Int32Constant(kSmiTagMask)); |
762 } | 762 } |
763 | 763 |
764 | 764 |
765 void SimplifiedLowering::LowerAllNodes() { | 765 void SimplifiedLowering::LowerAllNodes() { |
766 SimplifiedOperatorBuilder simplified(graph()->zone()); | 766 SimplifiedOperatorBuilder simplified(graph()->zone()); |
767 RepresentationChanger changer(jsgraph(), &simplified, machine(), | 767 RepresentationChanger changer(jsgraph(), &simplified, |
768 graph()->zone()->isolate()); | 768 graph()->zone()->isolate()); |
769 RepresentationSelector selector(jsgraph(), zone(), &changer); | 769 RepresentationSelector selector(jsgraph(), zone(), &changer); |
770 selector.Run(this); | 770 selector.Run(this); |
771 } | 771 } |
772 | 772 |
773 | 773 |
774 Node* SimplifiedLowering::Untag(Node* node) { | 774 Node* SimplifiedLowering::Untag(Node* node) { |
775 // TODO(titzer): factor this out to a TaggingScheme abstraction. | 775 // TODO(titzer): factor this out to a TaggingScheme abstraction. |
776 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); | 776 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); |
777 return graph()->NewNode(machine()->WordSar(), node, shift_amount); | 777 return graph()->NewNode(machine()->WordSar(), node, shift_amount); |
(...skipping 20 matching lines...) Expand all Loading... |
798 RepresentationOf(representation) == kRepTagged) { | 798 RepresentationOf(representation) == kRepTagged) { |
799 // Write barriers are only for writes into heap objects (i.e. tagged base). | 799 // Write barriers are only for writes into heap objects (i.e. tagged base). |
800 return kFullWriteBarrier; | 800 return kFullWriteBarrier; |
801 } | 801 } |
802 return kNoWriteBarrier; | 802 return kNoWriteBarrier; |
803 } | 803 } |
804 | 804 |
805 | 805 |
806 void SimplifiedLowering::DoLoadField(Node* node) { | 806 void SimplifiedLowering::DoLoadField(Node* node) { |
807 const FieldAccess& access = FieldAccessOf(node->op()); | 807 const FieldAccess& access = FieldAccessOf(node->op()); |
808 node->set_op(machine_.Load(access.machine_type)); | 808 node->set_op(machine()->Load(access.machine_type)); |
809 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 809 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
810 node->InsertInput(zone(), 1, offset); | 810 node->InsertInput(zone(), 1, offset); |
811 } | 811 } |
812 | 812 |
813 | 813 |
814 void SimplifiedLowering::DoStoreField(Node* node) { | 814 void SimplifiedLowering::DoStoreField(Node* node) { |
815 const FieldAccess& access = FieldAccessOf(node->op()); | 815 const FieldAccess& access = FieldAccessOf(node->op()); |
816 WriteBarrierKind kind = ComputeWriteBarrierKind( | 816 WriteBarrierKind kind = ComputeWriteBarrierKind( |
817 access.base_is_tagged, access.machine_type, access.type); | 817 access.base_is_tagged, access.machine_type, access.type); |
818 node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind))); | 818 node->set_op( |
| 819 machine()->Store(StoreRepresentation(access.machine_type, kind))); |
819 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 820 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
820 node->InsertInput(zone(), 1, offset); | 821 node->InsertInput(zone(), 1, offset); |
821 } | 822 } |
822 | 823 |
823 | 824 |
824 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, | 825 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, |
825 Node* index) { | 826 Node* index) { |
826 int element_size = ElementSizeOf(access.machine_type); | 827 int element_size = ElementSizeOf(access.machine_type); |
827 if (element_size != 1) { | 828 if (element_size != 1) { |
828 index = graph()->NewNode(machine()->Int32Mul(), | 829 index = graph()->NewNode(machine()->Int32Mul(), |
829 jsgraph()->Int32Constant(element_size), index); | 830 jsgraph()->Int32Constant(element_size), index); |
830 } | 831 } |
831 int fixed_offset = access.header_size - access.tag(); | 832 int fixed_offset = access.header_size - access.tag(); |
832 if (fixed_offset == 0) return index; | 833 if (fixed_offset == 0) return index; |
833 return graph()->NewNode(machine()->Int32Add(), index, | 834 return graph()->NewNode(machine()->Int32Add(), index, |
834 jsgraph()->Int32Constant(fixed_offset)); | 835 jsgraph()->Int32Constant(fixed_offset)); |
835 } | 836 } |
836 | 837 |
837 | 838 |
838 void SimplifiedLowering::DoLoadElement(Node* node) { | 839 void SimplifiedLowering::DoLoadElement(Node* node) { |
839 const ElementAccess& access = ElementAccessOf(node->op()); | 840 const ElementAccess& access = ElementAccessOf(node->op()); |
840 node->set_op(machine_.Load(access.machine_type)); | 841 node->set_op(machine()->Load(access.machine_type)); |
841 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 842 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
842 } | 843 } |
843 | 844 |
844 | 845 |
845 void SimplifiedLowering::DoStoreElement(Node* node) { | 846 void SimplifiedLowering::DoStoreElement(Node* node) { |
846 const ElementAccess& access = ElementAccessOf(node->op()); | 847 const ElementAccess& access = ElementAccessOf(node->op()); |
847 WriteBarrierKind kind = ComputeWriteBarrierKind( | 848 WriteBarrierKind kind = ComputeWriteBarrierKind( |
848 access.base_is_tagged, access.machine_type, access.type); | 849 access.base_is_tagged, access.machine_type, access.type); |
849 node->set_op(machine_.Store(StoreRepresentation(access.machine_type, kind))); | 850 node->set_op( |
| 851 machine()->Store(StoreRepresentation(access.machine_type, kind))); |
850 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 852 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
851 } | 853 } |
852 | 854 |
853 | 855 |
854 void SimplifiedLowering::DoStringAdd(Node* node) { | 856 void SimplifiedLowering::DoStringAdd(Node* node) { |
855 Callable callable = CodeFactory::StringAdd( | 857 Callable callable = CodeFactory::StringAdd( |
856 zone()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); | 858 zone()->isolate(), STRING_ADD_CHECK_NONE, NOT_TENURED); |
857 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; | 859 CallDescriptor::Flags flags = CallDescriptor::kNoFlags; |
858 CallDescriptor* desc = | 860 CallDescriptor* desc = |
859 Linkage::GetStubCallDescriptor(callable.descriptor(), 0, flags, zone()); | 861 Linkage::GetStubCallDescriptor(callable.descriptor(), 0, flags, zone()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 903 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
902 node->set_op(machine()->IntLessThanOrEqual()); | 904 node->set_op(machine()->IntLessThanOrEqual()); |
903 node->ReplaceInput(0, StringComparison(node, true)); | 905 node->ReplaceInput(0, StringComparison(node, true)); |
904 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 906 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
905 } | 907 } |
906 | 908 |
907 | 909 |
908 } // namespace compiler | 910 } // namespace compiler |
909 } // namespace internal | 911 } // namespace internal |
910 } // namespace v8 | 912 } // namespace v8 |
OLD | NEW |