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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 V(Word64Or) \ | 62 V(Word64Or) \ |
63 V(Word64And) \ | 63 V(Word64And) \ |
64 V(Word64Xor) \ | 64 V(Word64Xor) \ |
65 V(Word64Shr) \ | 65 V(Word64Shr) \ |
66 V(Word64Sar) \ | 66 V(Word64Sar) \ |
67 V(Word64Ror) \ | 67 V(Word64Ror) \ |
68 V(UintPtrGreaterThanOrEqual) | 68 V(UintPtrGreaterThanOrEqual) |
69 | 69 |
70 class CodeStubAssembler { | 70 class CodeStubAssembler { |
71 public: | 71 public: |
72 // CodeStubAssembler for generating stubs. | |
72 // |result_size| specifies the number of results returned by the stub. | 73 // |result_size| specifies the number of results returned by the stub. |
73 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 74 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
74 CodeStubAssembler(Isolate* isolate, Zone* zone, | 75 CodeStubAssembler(Isolate* isolate, Zone* zone, |
75 const CallInterfaceDescriptor& descriptor, | 76 const CallInterfaceDescriptor& descriptor, |
76 Code::Flags flags, const char* name, | 77 Code::Flags flags, const char* name, |
77 size_t result_size = 1); | 78 size_t result_size = 1); |
79 | |
80 // CodeStubAssembler for generating JS functions. | |
81 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, | |
82 Code::Flags flags, const char* name); | |
83 | |
78 virtual ~CodeStubAssembler(); | 84 virtual ~CodeStubAssembler(); |
79 | 85 |
80 Handle<Code> GenerateCode(); | 86 Handle<Code> GenerateCode(); |
81 | 87 |
82 class Label; | 88 class Label; |
83 class Variable { | 89 class Variable { |
84 public: | 90 public: |
85 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 91 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
86 void Bind(Node* value); | 92 void Bind(Node* value); |
87 Node* value() const; | 93 Node* value() const; |
(...skipping 10 matching lines...) Expand all Loading... | |
98 // Base Assembler | 104 // Base Assembler |
99 // =========================================================================== | 105 // =========================================================================== |
100 | 106 |
101 // Constants. | 107 // Constants. |
102 Node* Int32Constant(int value); | 108 Node* Int32Constant(int value); |
103 Node* IntPtrConstant(intptr_t value); | 109 Node* IntPtrConstant(intptr_t value); |
104 Node* NumberConstant(double value); | 110 Node* NumberConstant(double value); |
105 Node* HeapConstant(Handle<HeapObject> object); | 111 Node* HeapConstant(Handle<HeapObject> object); |
106 Node* BooleanConstant(bool value); | 112 Node* BooleanConstant(bool value); |
107 Node* ExternalConstant(ExternalReference address); | 113 Node* ExternalConstant(ExternalReference address); |
114 Node* NullConstant(); | |
115 Node* UndefinedConstant(); | |
108 | 116 |
109 Node* Parameter(int value); | 117 Node* Parameter(int value); |
110 void Return(Node* value); | 118 void Return(Node* value); |
111 | 119 |
112 void Bind(Label* label); | 120 void Bind(Label* label); |
113 void Goto(Label* label); | 121 void Goto(Label* label); |
114 void Branch(Node* condition, Label* true_label, Label* false_label); | 122 void Branch(Node* condition, Label* true_label, Label* false_label); |
115 | 123 |
116 void Switch(Node* index, Label* default_label, int32_t* case_values, | 124 void Switch(Node* index, Label* default_label, int32_t* case_values, |
117 Label** case_labels, size_t case_count); | 125 Label** case_labels, size_t case_count); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 187 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
180 size_t result_size = 1); | 188 size_t result_size = 1); |
181 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 189 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
182 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, | 190 Node* context, Node* arg1, Node* arg2, Node* arg3, Node* arg4, |
183 Node* arg5, size_t result_size = 1); | 191 Node* arg5, size_t result_size = 1); |
184 | 192 |
185 Node* TailCallStub(CodeStub& stub, Node** args); | 193 Node* TailCallStub(CodeStub& stub, Node** args); |
186 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 194 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
187 Node** args, size_t result_size = 1); | 195 Node** args, size_t result_size = 1); |
188 | 196 |
197 // Calls w/ custom CallDescriptor. Prefer the call methods above. | |
198 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | |
danno
2016/02/18 15:01:15
Nit: The TailCallStub call doesn't append the "N"
| |
199 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | |
200 | |
189 // =========================================================================== | 201 // =========================================================================== |
190 // Macros | 202 // Macros |
191 // =========================================================================== | 203 // =========================================================================== |
192 | 204 |
193 // Tag and untag Smi values. | 205 // Tag and untag Smi values. |
194 Node* SmiTag(Node* value); | 206 Node* SmiTag(Node* value); |
195 Node* SmiUntag(Node* value); | 207 Node* SmiUntag(Node* value); |
196 | 208 |
197 // Load a value from the root array. | 209 // Load a value from the root array. |
198 Node* LoadRoot(Heap::RootListIndex root_index); | 210 Node* LoadRoot(Heap::RootListIndex root_index); |
199 | 211 |
200 // Check a value for smi-ness | 212 // Check a value for smi-ness |
201 Node* WordIsSmi(Node* a); | 213 Node* WordIsSmi(Node* a); |
202 | 214 |
203 // Load an object pointer from a buffer that isn't in the heap. | 215 // Load an object pointer from a buffer that isn't in the heap. |
204 Node* LoadBufferObject(Node* buffer, int offset); | 216 Node* LoadBufferObject(Node* buffer, int offset); |
205 // Load a field from an object on the heap. | 217 // Load a field from an object on the heap. |
206 Node* LoadObjectField(Node* object, int offset); | 218 Node* LoadObjectField(Node* object, int offset); |
207 | 219 |
220 // Load a machine-typed value from an object on the heap, or from a native | |
221 // (C++) object. | |
222 Node* LoadObjectFieldTyped(Node* object, int offset, MachineType rep); | |
danno
2016/02/18 15:01:15
Any reason to not combine these with the LoadObjec
| |
223 Node* LoadNativeFieldTyped(Node* object, int offset, MachineType rep); | |
224 | |
208 // Load an array element from a FixedArray. | 225 // Load an array element from a FixedArray. |
209 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 226 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
210 int additional_offset = 0); | 227 int additional_offset = 0); |
211 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 228 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
212 | 229 |
213 protected: | 230 protected: |
214 // Protected helpers which delegate to RawMachineAssembler. | 231 // Protected helpers which delegate to RawMachineAssembler. |
215 Graph* graph(); | 232 Graph* graph(); |
216 Isolate* isolate(); | 233 Isolate* isolate(); |
217 Zone* zone(); | 234 Zone* zone(); |
218 | 235 |
219 // Enables subclasses to perform operations before and after a call. | 236 // Enables subclasses to perform operations before and after a call. |
220 virtual void CallPrologue(); | 237 virtual void CallPrologue(); |
221 virtual void CallEpilogue(); | 238 virtual void CallEpilogue(); |
222 | 239 |
223 private: | 240 private: |
224 friend class CodeStubAssemblerTester; | 241 friend class CodeStubAssemblerTester; |
225 | 242 |
226 Node* CallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 243 CodeStubAssembler(Isolate* isolate, Zone* zone, |
227 Node* TailCallN(CallDescriptor* descriptor, Node* code_target, Node** args); | 244 CallDescriptor* call_descriptor, Code::Flags flags, |
228 | 245 const char* name); |
229 Node* SmiShiftBitsConstant(); | 246 Node* SmiShiftBitsConstant(); |
230 | 247 |
231 base::SmartPointer<RawMachineAssembler> raw_assembler_; | 248 base::SmartPointer<RawMachineAssembler> raw_assembler_; |
232 Code::Flags flags_; | 249 Code::Flags flags_; |
233 const char* name_; | 250 const char* name_; |
234 bool code_generated_; | 251 bool code_generated_; |
235 ZoneVector<Variable::Impl*> variables_; | 252 ZoneVector<Variable::Impl*> variables_; |
236 | 253 |
237 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); | 254 DISALLOW_COPY_AND_ASSIGN(CodeStubAssembler); |
238 }; | 255 }; |
(...skipping 23 matching lines...) Expand all Loading... | |
262 // Map of variables to the list of value nodes that have been added from each | 279 // Map of variables to the list of value nodes that have been added from each |
263 // merge path in their order of merging. | 280 // merge path in their order of merging. |
264 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 281 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
265 }; | 282 }; |
266 | 283 |
267 } // namespace compiler | 284 } // namespace compiler |
268 } // namespace internal | 285 } // namespace internal |
269 } // namespace v8 | 286 } // namespace v8 |
270 | 287 |
271 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 288 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |