OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
6 #define V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 // Clients of this interface shouldn't depend on lots of compiler internals. | 10 // Clients of this interface shouldn't depend on lots of compiler internals. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 V(WordXor) \ | 46 V(WordXor) \ |
47 V(WordShl) \ | 47 V(WordShl) \ |
48 V(WordShr) \ | 48 V(WordShr) \ |
49 V(WordSar) \ | 49 V(WordSar) \ |
50 V(WordRor) \ | 50 V(WordRor) \ |
51 V(Word32Equal) \ | 51 V(Word32Equal) \ |
52 V(Word32NotEqual) \ | 52 V(Word32NotEqual) \ |
53 V(Word32Or) \ | 53 V(Word32Or) \ |
54 V(Word32And) \ | 54 V(Word32And) \ |
55 V(Word32Xor) \ | 55 V(Word32Xor) \ |
56 V(Word32Shl) \ | |
56 V(Word32Shr) \ | 57 V(Word32Shr) \ |
57 V(Word32Sar) \ | 58 V(Word32Sar) \ |
58 V(Word32Ror) \ | 59 V(Word32Ror) \ |
59 V(Word64Equal) \ | 60 V(Word64Equal) \ |
60 V(Word64NotEqual) \ | 61 V(Word64NotEqual) \ |
61 V(Word64Or) \ | 62 V(Word64Or) \ |
62 V(Word64And) \ | 63 V(Word64And) \ |
63 V(Word64Xor) \ | 64 V(Word64Xor) \ |
64 V(Word64Shr) \ | 65 V(Word64Shr) \ |
65 V(Word64Sar) \ | 66 V(Word64Sar) \ |
66 V(Word64Ror) | 67 V(Word64Ror) \ |
68 V(UintPtrGreaterThanOrEqual) \ | |
69 V(UintPtrLessThanOrEqual) | |
epertoso
2016/02/10 11:05:37
I think you just need one of these two. It doesn't
rmcilroy
2016/02/10 16:13:39
Sure, I was just trying to keep things consistent
| |
67 | 70 |
68 class CodeStubAssembler { | 71 class CodeStubAssembler { |
69 public: | 72 public: |
70 CodeStubAssembler(Isolate* isolate, Zone* zone, | 73 CodeStubAssembler(Isolate* isolate, Zone* zone, |
71 const CallInterfaceDescriptor& descriptor, | 74 const CallInterfaceDescriptor& descriptor, |
72 Code::Flags flags, const char* name); | 75 Code::Flags flags, const char* name, |
76 size_t result_size = 1); | |
73 virtual ~CodeStubAssembler(); | 77 virtual ~CodeStubAssembler(); |
74 | 78 |
75 Handle<Code> GenerateCode(); | 79 Handle<Code> GenerateCode(); |
76 | 80 |
77 class Label; | 81 class Label; |
78 class Variable { | 82 class Variable { |
79 public: | 83 public: |
80 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 84 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
81 void Bind(Node* value); | 85 void Bind(Node* value); |
82 Node* value() const; | 86 Node* value() const; |
(...skipping 25 matching lines...) Expand all Loading... | |
108 void Goto(Label* label); | 112 void Goto(Label* label); |
109 void Branch(Node* condition, Label* true_label, Label* false_label); | 113 void Branch(Node* condition, Label* true_label, Label* false_label); |
110 | 114 |
111 void Switch(Node* index, Label* default_label, int32_t* case_values, | 115 void Switch(Node* index, Label* default_label, int32_t* case_values, |
112 Label** case_labels, size_t case_count); | 116 Label** case_labels, size_t case_count); |
113 | 117 |
114 // Access to the frame pointer | 118 // Access to the frame pointer |
115 Node* LoadFramePointer(); | 119 Node* LoadFramePointer(); |
116 Node* LoadParentFramePointer(); | 120 Node* LoadParentFramePointer(); |
117 | 121 |
122 // Access to the stack pointer | |
123 Node* LoadStackPointer(); | |
124 | |
125 // Load raw memory location. | |
126 Node* Load(MachineType rep, Node* base); | |
127 Node* Load(MachineType rep, Node* base, Node* index); | |
128 | |
129 // Store value to raw memory location. | |
130 Node* Store(MachineRepresentation rep, Node* base, Node* value); | |
131 Node* Store(MachineRepresentation rep, Node* base, Node* index, Node* value); | |
132 Node* StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* value); | |
133 Node* StoreNoWriteBarrier(MachineRepresentation rep, Node* base, Node* index, | |
134 Node* value); | |
135 | |
118 // Basic arithmetic operations. | 136 // Basic arithmetic operations. |
119 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); | 137 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); |
120 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) | 138 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) |
121 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP | 139 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP |
122 | 140 |
123 Node* WordShl(Node* value, int shift); | 141 Node* WordShl(Node* value, int shift); |
124 | 142 |
143 // Conversions | |
144 Node* ChangeInt32ToInt64(Node* value); | |
145 | |
146 // Projections | |
147 Node* Projection(int index, Node* value); | |
148 | |
125 // Calls | 149 // Calls |
150 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); | |
126 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); | 151 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); |
127 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 152 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
128 Node* arg2); | 153 Node* arg2); |
154 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | |
155 Node* arg2, Node* arg3); | |
156 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | |
157 Node* arg2, Node* arg3, Node* arg4); | |
158 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | |
159 Node* arg2, Node* arg3, Node* arg4, Node* arg5); | |
129 | 160 |
130 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 161 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
131 Node* arg1); | 162 Node* arg1); |
132 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 163 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
133 Node* arg1, Node* arg2); | 164 Node* arg1, Node* arg2); |
134 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 165 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
135 Node* arg1, Node* arg2, Node* arg3); | 166 Node* arg1, Node* arg2, Node* arg3); |
136 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 167 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
137 Node* arg1, Node* arg2, Node* arg3, Node* arg4); | 168 Node* arg1, Node* arg2, Node* arg3, Node* arg4); |
138 | 169 |
170 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | |
171 Node* context, Node* arg1, size_t result_size = 1); | |
172 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | |
173 Node* context, Node* arg1, Node* arg2, size_t result_size = 1); | |
174 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | |
175 Node* context, Node* arg1, Node* arg2, Node* arg3, | |
176 size_t result_size = 1); | |
177 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | |
178 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | |
179 size_t result_size = 1); | |
180 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | |
181 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | |
182 Node* arg5, size_t result_size = 1); | |
183 | |
139 Node* TailCallStub(CodeStub& stub, Node** args); | 184 Node* TailCallStub(CodeStub& stub, Node** args); |
140 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 185 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
141 Node** args); | 186 Node** args, size_t result_size = 1); |
142 | 187 |
143 // =========================================================================== | 188 // =========================================================================== |
144 // Macros | 189 // Macros |
145 // =========================================================================== | 190 // =========================================================================== |
146 | 191 |
147 // Tag and untag Smi values. | 192 // Tag and untag Smi values. |
148 Node* SmiTag(Node* value); | 193 Node* SmiTag(Node* value); |
149 Node* SmiUntag(Node* value); | 194 Node* SmiUntag(Node* value); |
150 | 195 |
151 // Load a value from the root array. | 196 // Load a value from the root array. |
152 Node* LoadRoot(Heap::RootListIndex root_index); | 197 Node* LoadRoot(Heap::RootListIndex root_index); |
153 | 198 |
154 // Check a value for smi-ness | 199 // Check a value for smi-ness |
155 Node* WordIsSmi(Node* a); | 200 Node* WordIsSmi(Node* a); |
156 | 201 |
157 // Load an object pointer from a buffer that isn't in the heap. | 202 // Load an object pointer from a buffer that isn't in the heap. |
158 Node* LoadBufferObject(Node* buffer, int offset); | 203 Node* LoadBufferObject(Node* buffer, int offset); |
159 // Load a field from an object on the heap. | 204 // Load a field from an object on the heap. |
160 Node* LoadObjectField(Node* object, int offset); | 205 Node* LoadObjectField(Node* object, int offset); |
161 | 206 |
162 // Load an array element from a FixedArray. | 207 // Load an array element from a FixedArray. |
163 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 208 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
164 int additional_offset = 0); | 209 int additional_offset = 0); |
165 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 210 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
166 | 211 |
212 protected: | |
213 // Protected helpers which delegate to RawMachineAssembler. | |
214 Graph* graph(); | |
215 Isolate* isolate(); | |
216 Zone* zone(); | |
217 | |
218 // Enables subclasses to perform operations before and after a call. | |
219 virtual void CallPrologue(); | |
220 virtual void CallEpilogue(); | |
221 | |
167 private: | 222 private: |
168 friend class CodeStubAssemblerTester; | 223 friend class CodeStubAssemblerTester; |
169 | 224 |
170 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 225 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
171 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 226 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); |
172 | 227 |
173 Node* SmiShiftBitsConstant(); | 228 Node* SmiShiftBitsConstant(); |
174 | 229 |
175 // Private helpers which delegate to RawMachineAssembler. | |
176 Graph* graph(); | |
177 Isolate* isolate(); | |
178 Zone* zone(); | |
179 | |
180 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 230 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
181 Code::Flags flags_; | 231 Code::Flags flags_; |
182 const char* name_; | 232 const char* name_; |
183 bool code_generated_; | 233 bool code_generated_; |
184 ZoneVector<Variable::Impl*> variables_; | 234 ZoneVector<Variable::Impl*> variables_; |
185 | 235 |
186 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); | 236 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
187 }; | 237 }; |
188 | 238 |
189 class CodeStubAssembler::Label { | 239 class CodeStubAssembler::Label { |
(...skipping 21 matching lines...) Expand all Loading... | |
211 // Map of variables to the list of value nodes that have been added from each | 261 // Map of variables to the list of value nodes that have been added from each |
212 // merge path in their order of merging. | 262 // merge path in their order of merging. |
213 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 263 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
214 }; | 264 }; |
215 | 265 |
216 } // namespace compiler | 266 } // namespace compiler |
217 } // namespace internal | 267 } // namespace internal |
218 } // namespace v8 | 268 } // namespace v8 |
219 | 269 |
220 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 270 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |