| 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 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 6 #define V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // | 33 // |
| 34 // Also note that the generated graph is only valid together with the generated | 34 // Also note that the generated graph is only valid together with the generated |
| 35 // schedule, using one without the other is invalid as the graph is inherently | 35 // schedule, using one without the other is invalid as the graph is inherently |
| 36 // non-schedulable due to missing control and effect dependencies. | 36 // non-schedulable due to missing control and effect dependencies. |
| 37 class RawMachineAssembler { | 37 class RawMachineAssembler { |
| 38 public: | 38 public: |
| 39 RawMachineAssembler( | 39 RawMachineAssembler( |
| 40 Isolate* isolate, Graph* graph, CallDescriptor* call_descriptor, | 40 Isolate* isolate, Graph* graph, CallDescriptor* call_descriptor, |
| 41 MachineRepresentation word = MachineType::PointerRepresentation(), | 41 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 42 MachineOperatorBuilder::Flags flags = | 42 MachineOperatorBuilder::Flags flags = |
| 43 MachineOperatorBuilder::Flag::kNoFlags); | 43 MachineOperatorBuilder::Flag::kNoFlags, |
| 44 MachineOperatorBuilder::AlignmentRequirements alignment_requirements = |
| 45 MachineOperatorBuilder::AlignmentRequirements:: |
| 46 FullUnalignedAccessSupport()); |
| 44 ~RawMachineAssembler() {} | 47 ~RawMachineAssembler() {} |
| 45 | 48 |
| 46 Isolate* isolate() const { return isolate_; } | 49 Isolate* isolate() const { return isolate_; } |
| 47 Graph* graph() const { return graph_; } | 50 Graph* graph() const { return graph_; } |
| 48 Zone* zone() const { return graph()->zone(); } | 51 Zone* zone() const { return graph()->zone(); } |
| 49 MachineOperatorBuilder* machine() { return &machine_; } | 52 MachineOperatorBuilder* machine() { return &machine_; } |
| 50 CommonOperatorBuilder* common() { return &common_; } | 53 CommonOperatorBuilder* common() { return &common_; } |
| 51 CallDescriptor* call_descriptor() const { return call_descriptor_; } | 54 CallDescriptor* call_descriptor() const { return call_descriptor_; } |
| 52 | 55 |
| 53 // Finalizes the schedule and exports it to be used for code generation. Note | 56 // Finalizes the schedule and exports it to be used for code generation. Note |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 Node* Store(MachineRepresentation rep, Node* base, Node* value, | 129 Node* Store(MachineRepresentation rep, Node* base, Node* value, |
| 127 WriteBarrierKind write_barrier) { | 130 WriteBarrierKind write_barrier) { |
| 128 return Store(rep, base, IntPtrConstant(0), value, write_barrier); | 131 return Store(rep, base, IntPtrConstant(0), value, write_barrier); |
| 129 } | 132 } |
| 130 Node* Store(MachineRepresentation rep, Node* base, Node* index, Node* value, | 133 Node* Store(MachineRepresentation rep, Node* base, Node* index, Node* value, |
| 131 WriteBarrierKind write_barrier) { | 134 WriteBarrierKind write_barrier) { |
| 132 return AddNode(machine()->Store(StoreRepresentation(rep, write_barrier)), | 135 return AddNode(machine()->Store(StoreRepresentation(rep, write_barrier)), |
| 133 base, index, value); | 136 base, index, value); |
| 134 } | 137 } |
| 135 | 138 |
| 139 // Unaligned memory operations |
| 140 Node* UnalignedLoad(MachineType rep, Node* base) { |
| 141 return UnalignedLoad(rep, base, IntPtrConstant(0)); |
| 142 } |
| 143 Node* UnalignedLoad(MachineType rep, Node* base, Node* index) { |
| 144 if (machine()->UnalignedLoadSupported(rep, 1)) { |
| 145 return AddNode(machine()->Load(rep), base, index); |
| 146 } else { |
| 147 return AddNode(machine()->UnalignedLoad(rep), base, index); |
| 148 } |
| 149 } |
| 150 Node* UnalignedStore(MachineRepresentation rep, Node* base, Node* value) { |
| 151 return UnalignedStore(rep, base, IntPtrConstant(0), value); |
| 152 } |
| 153 Node* UnalignedStore(MachineRepresentation rep, Node* base, Node* index, |
| 154 Node* value) { |
| 155 MachineType t = MachineType::TypeForRepresentation(rep); |
| 156 if (machine()->UnalignedStoreSupported(t, 1)) { |
| 157 return AddNode(machine()->Store(StoreRepresentation( |
| 158 rep, WriteBarrierKind::kNoWriteBarrier)), |
| 159 base, index, value); |
| 160 } else { |
| 161 return AddNode( |
| 162 machine()->UnalignedStore(UnalignedStoreRepresentation(rep)), base, |
| 163 index, value); |
| 164 } |
| 165 } |
| 166 |
| 136 // Atomic memory operations. | 167 // Atomic memory operations. |
| 137 Node* AtomicLoad(MachineType rep, Node* base, Node* index) { | 168 Node* AtomicLoad(MachineType rep, Node* base, Node* index) { |
| 138 return AddNode(machine()->AtomicLoad(rep), base, index); | 169 return AddNode(machine()->AtomicLoad(rep), base, index); |
| 139 } | 170 } |
| 140 Node* AtomicStore(MachineRepresentation rep, Node* base, Node* index, | 171 Node* AtomicStore(MachineRepresentation rep, Node* base, Node* index, |
| 141 Node* value) { | 172 Node* value) { |
| 142 return AddNode(machine()->AtomicStore(rep), base, index, value); | 173 return AddNode(machine()->AtomicStore(rep), base, index, value); |
| 143 } | 174 } |
| 144 | 175 |
| 145 // Arithmetic Operations. | 176 // Arithmetic Operations. |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 // Parameters. | 671 // Parameters. |
| 641 Node* Parameter(size_t index); | 672 Node* Parameter(size_t index); |
| 642 | 673 |
| 643 // Pointer utilities. | 674 // Pointer utilities. |
| 644 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { | 675 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { |
| 645 return Load(rep, PointerConstant(address), Int32Constant(offset)); | 676 return Load(rep, PointerConstant(address), Int32Constant(offset)); |
| 646 } | 677 } |
| 647 Node* StoreToPointer(void* address, MachineRepresentation rep, Node* node) { | 678 Node* StoreToPointer(void* address, MachineRepresentation rep, Node* node) { |
| 648 return Store(rep, PointerConstant(address), node, kNoWriteBarrier); | 679 return Store(rep, PointerConstant(address), node, kNoWriteBarrier); |
| 649 } | 680 } |
| 681 Node* UnalignedLoadFromPointer(void* address, MachineType rep, |
| 682 int32_t offset = 0) { |
| 683 return UnalignedLoad(rep, PointerConstant(address), Int32Constant(offset)); |
| 684 } |
| 685 Node* UnalignedStoreToPointer(void* address, MachineRepresentation rep, |
| 686 Node* node) { |
| 687 return UnalignedStore(rep, PointerConstant(address), node); |
| 688 } |
| 650 Node* StringConstant(const char* string) { | 689 Node* StringConstant(const char* string) { |
| 651 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); | 690 return HeapConstant(isolate()->factory()->InternalizeUtf8String(string)); |
| 652 } | 691 } |
| 653 | 692 |
| 654 // Call a given call descriptor and the given arguments. | 693 // Call a given call descriptor and the given arguments. |
| 655 Node* CallN(CallDescriptor* desc, Node* function, Node** args); | 694 Node* CallN(CallDescriptor* desc, Node* function, Node** args); |
| 656 // Call a given call descriptor and the given arguments and frame-state. | 695 // Call a given call descriptor and the given arguments and frame-state. |
| 657 Node* CallNWithFrameState(CallDescriptor* desc, Node* function, Node** args, | 696 Node* CallNWithFrameState(CallDescriptor* desc, Node* function, Node** args, |
| 658 Node* frame_state); | 697 Node* frame_state); |
| 659 // Call to a runtime function with zero arguments. | 698 // Call to a runtime function with zero arguments. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 bool deferred_; | 831 bool deferred_; |
| 793 friend class RawMachineAssembler; | 832 friend class RawMachineAssembler; |
| 794 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); | 833 DISALLOW_COPY_AND_ASSIGN(RawMachineLabel); |
| 795 }; | 834 }; |
| 796 | 835 |
| 797 } // namespace compiler | 836 } // namespace compiler |
| 798 } // namespace internal | 837 } // namespace internal |
| 799 } // namespace v8 | 838 } // namespace v8 |
| 800 | 839 |
| 801 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ | 840 #endif // V8_COMPILER_RAW_MACHINE_ASSEMBLER_H_ |
| OLD | NEW |