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 25 matching lines...) Expand all Loading... | |
36 #define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \ | 36 #define CODE_STUB_ASSEMBLER_BINARY_OP_LIST(V) \ |
37 V(Float64Equal) \ | 37 V(Float64Equal) \ |
38 V(Float64LessThan) \ | 38 V(Float64LessThan) \ |
39 V(Float64LessThanOrEqual) \ | 39 V(Float64LessThanOrEqual) \ |
40 V(IntPtrAdd) \ | 40 V(IntPtrAdd) \ |
41 V(IntPtrSub) \ | 41 V(IntPtrSub) \ |
42 V(Int32Add) \ | 42 V(Int32Add) \ |
43 V(Int32Sub) \ | 43 V(Int32Sub) \ |
44 V(Int32Mul) \ | 44 V(Int32Mul) \ |
45 V(Int32GreaterThanOrEqual) \ | 45 V(Int32GreaterThanOrEqual) \ |
46 V(Int32LessThan) \ | |
46 V(WordEqual) \ | 47 V(WordEqual) \ |
47 V(WordNotEqual) \ | 48 V(WordNotEqual) \ |
48 V(WordOr) \ | 49 V(WordOr) \ |
49 V(WordAnd) \ | 50 V(WordAnd) \ |
50 V(WordXor) \ | 51 V(WordXor) \ |
51 V(WordShl) \ | 52 V(WordShl) \ |
52 V(WordShr) \ | 53 V(WordShr) \ |
53 V(WordSar) \ | 54 V(WordSar) \ |
54 V(WordRor) \ | 55 V(WordRor) \ |
55 V(Word32Equal) \ | 56 V(Word32Equal) \ |
56 V(Word32NotEqual) \ | 57 V(Word32NotEqual) \ |
57 V(Word32Or) \ | 58 V(Word32Or) \ |
58 V(Word32And) \ | 59 V(Word32And) \ |
59 V(Word32Xor) \ | 60 V(Word32Xor) \ |
60 V(Word32Shl) \ | 61 V(Word32Shl) \ |
61 V(Word32Shr) \ | 62 V(Word32Shr) \ |
62 V(Word32Sar) \ | 63 V(Word32Sar) \ |
63 V(Word32Ror) \ | 64 V(Word32Ror) \ |
64 V(Word64Equal) \ | 65 V(Word64Equal) \ |
65 V(Word64NotEqual) \ | 66 V(Word64NotEqual) \ |
66 V(Word64Or) \ | 67 V(Word64Or) \ |
67 V(Word64And) \ | 68 V(Word64And) \ |
68 V(Word64Xor) \ | 69 V(Word64Xor) \ |
69 V(Word64Shr) \ | 70 V(Word64Shr) \ |
70 V(Word64Sar) \ | 71 V(Word64Sar) \ |
71 V(Word64Ror) \ | 72 V(Word64Ror) \ |
72 V(UintPtrGreaterThanOrEqual) | 73 V(UintPtrGreaterThanOrEqual) |
73 | 74 |
75 #define CODE_STUB_ASSEMBLER_UNARY_OP_LIST(V) \ | |
76 V(ChangeFloat64ToUint32) \ | |
77 V(ChangeInt32ToInt64) \ | |
78 V(ChangeUint32ToFloat64) | |
79 | |
74 class CodeStubAssembler { | 80 class CodeStubAssembler { |
75 public: | 81 public: |
82 // Create with CallStub linkage. | |
76 // |result_size| specifies the number of results returned by the stub. | 83 // |result_size| specifies the number of results returned by the stub. |
77 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. | 84 // TODO(rmcilroy): move result_size to the CallInterfaceDescriptor. |
78 CodeStubAssembler(Isolate* isolate, Zone* zone, | 85 CodeStubAssembler(Isolate* isolate, Zone* zone, |
79 const CallInterfaceDescriptor& descriptor, | 86 const CallInterfaceDescriptor& descriptor, |
80 Code::Flags flags, const char* name, | 87 Code::Flags flags, const char* name, |
81 size_t result_size = 1); | 88 size_t result_size = 1); |
89 | |
90 // Create with JSCall linkage. | |
91 CodeStubAssembler(Isolate* isolate, Zone* zone, int parameter_count, | |
92 Code::Flags flags, const char* name); | |
93 | |
82 virtual ~CodeStubAssembler(); | 94 virtual ~CodeStubAssembler(); |
83 | 95 |
84 Handle<Code> GenerateCode(); | 96 Handle<Code> GenerateCode(); |
85 | 97 |
86 class Label; | 98 class Label; |
87 class Variable { | 99 class Variable { |
88 public: | 100 public: |
89 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); | 101 explicit Variable(CodeStubAssembler* assembler, MachineRepresentation rep); |
90 void Bind(Node* value); | 102 void Bind(Node* value); |
91 Node* value() const; | 103 Node* value() const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 Node* value); | 153 Node* value); |
142 | 154 |
143 // Basic arithmetic operations. | 155 // Basic arithmetic operations. |
144 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); | 156 #define DECLARE_CODE_STUB_ASSEMBER_BINARY_OP(name) Node* name(Node* a, Node* b); |
145 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) | 157 CODE_STUB_ASSEMBLER_BINARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_BINARY_OP) |
146 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP | 158 #undef DECLARE_CODE_STUB_ASSEMBER_BINARY_OP |
147 | 159 |
148 Node* WordShl(Node* value, int shift); | 160 Node* WordShl(Node* value, int shift); |
149 | 161 |
150 // Conversions | 162 // Conversions |
151 Node* ChangeInt32ToInt64(Node* value); | 163 #define DECLARE_CODE_STUB_ASSEMBER_UNARY_OP(name) Node* name(Node* a); |
164 CODE_STUB_ASSEMBLER_UNARY_OP_LIST(DECLARE_CODE_STUB_ASSEMBER_UNARY_OP) | |
165 #undef DECLARE_CODE_STUB_ASSEMBER_UNARY_OP | |
152 | 166 |
153 // Projections | 167 // Projections |
154 Node* Projection(int index, Node* value); | 168 Node* Projection(int index, Node* value); |
155 | 169 |
156 // Calls | 170 // Calls |
157 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); | 171 Node* CallRuntime(Runtime::FunctionId function_id, Node* context); |
158 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); | 172 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1); |
159 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 173 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
160 Node* arg2); | 174 Node* arg2); |
161 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 175 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
162 Node* arg2, Node* arg3); | 176 Node* arg2, Node* arg3); |
163 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 177 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
164 Node* arg2, Node* arg3, Node* arg4); | 178 Node* arg2, Node* arg3, Node* arg4); |
165 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, | 179 Node* CallRuntime(Runtime::FunctionId function_id, Node* context, Node* arg1, |
166 Node* arg2, Node* arg3, Node* arg4, Node* arg5); | 180 Node* arg2, Node* arg3, Node* arg4, Node* arg5); |
167 | 181 |
182 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context); | |
168 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 183 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
169 Node* arg1); | 184 Node* arg1); |
170 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 185 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
171 Node* arg1, Node* arg2); | 186 Node* arg1, Node* arg2); |
172 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 187 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
173 Node* arg1, Node* arg2, Node* arg3); | 188 Node* arg1, Node* arg2, Node* arg3); |
174 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, | 189 Node* TailCallRuntime(Runtime::FunctionId function_id, Node* context, |
175 Node* arg1, Node* arg2, Node* arg3, Node* arg4); | 190 Node* arg1, Node* arg2, Node* arg3, Node* arg4); |
176 | 191 |
177 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, | 192 Node* CallStub(const CallInterfaceDescriptor& descriptor, Node* target, |
(...skipping 11 matching lines...) Expand all Loading... | |
189 Node* arg5, size_t result_size = 1); | 204 Node* arg5, size_t result_size = 1); |
190 | 205 |
191 Node* TailCallStub(CodeStub& stub, Node** args); | 206 Node* TailCallStub(CodeStub& stub, Node** args); |
192 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, | 207 Node* TailCall(const CallInterfaceDescriptor& descriptor, Node* target, |
193 Node** args, size_t result_size = 1); | 208 Node** args, size_t result_size = 1); |
194 | 209 |
195 // =========================================================================== | 210 // =========================================================================== |
196 // Macros | 211 // Macros |
197 // =========================================================================== | 212 // =========================================================================== |
198 | 213 |
199 // Tag and untag Smi values. | 214 // Tag a Word as a Smi value. |
200 Node* SmiTag(Node* value); | 215 Node* SmiTag(Node* value); |
216 // Untag a Smi value as a Word. | |
201 Node* SmiUntag(Node* value); | 217 Node* SmiUntag(Node* value); |
218 // Untag an Smi value as a 32-bit value. | |
219 Node* SmiUntag32(Node* value); | |
Benedikt Meurer
2016/03/01 04:54:44
Nit: Rename to SmiToInt32
binji
2016/03/01 21:56:38
Done.
| |
202 | 220 |
203 // Smi operations. | 221 // Smi operations. |
204 Node* SmiAdd(Node* a, Node* b); | 222 Node* SmiAdd(Node* a, Node* b); |
205 Node* SmiEqual(Node* a, Node* b); | 223 Node* SmiEqual(Node* a, Node* b); |
206 | 224 |
207 // Load a value from the root array. | 225 // Load a value from the root array. |
208 Node* LoadRoot(Heap::RootListIndex root_index); | 226 Node* LoadRoot(Heap::RootListIndex root_index); |
209 | 227 |
210 // Check a value for smi-ness | 228 // Check a value for smi-ness |
211 Node* WordIsSmi(Node* a); | 229 Node* WordIsSmi(Node* a); |
212 | 230 |
213 // Load an object pointer from a buffer that isn't in the heap. | 231 // Load an object pointer from a buffer that isn't in the heap. |
214 Node* LoadBufferObject(Node* buffer, int offset); | 232 Node* LoadBufferObject(Node* buffer, int offset); |
215 // Load a field from an object on the heap. | 233 // Load a field from an object on the heap. |
216 Node* LoadObjectField(Node* object, int offset); | 234 Node* LoadObjectField(Node* object, int offset); |
235 // Load the HeapNumber value from a HeapNumber object. | |
236 Node* LoadHeapNumber(Node* object); | |
Benedikt Meurer
2016/03/01 04:54:44
Nit: Rename to LoadHeapNumberValue
binji
2016/03/01 21:56:38
Done.
| |
217 | 237 |
218 // Load an array element from a FixedArray. | 238 // Load an array element from a FixedArray. |
219 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 239 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
220 int additional_offset = 0); | 240 int additional_offset = 0); |
221 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 241 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
222 | 242 |
243 Node* InstanceType(Node* object); | |
Jarin
2016/02/29 20:04:43
InstanceType -> LoadInstanceType?
binji
2016/03/01 21:56:38
Done.
| |
244 | |
245 // Returns a node that is true if the given bit is set in |word32|. | |
246 template <typename T> | |
247 Node* BitFieldValue(Node* word32) { | |
Benedikt Meurer
2016/03/01 04:54:44
Nit: Rename to BitFieldDecode
binji
2016/03/01 21:56:38
Done.
| |
248 return BitFieldValue(word32, T::kShift, T::kMask); | |
249 } | |
250 | |
251 Node* BitFieldValue(Node* word32, uint32_t shift, uint32_t mask); | |
Benedikt Meurer
2016/03/01 04:54:44
Nit: Rename to BitFieldDecode
binji
2016/03/01 21:56:38
Done.
| |
252 | |
223 protected: | 253 protected: |
224 // Protected helpers which delegate to RawMachineAssembler. | 254 // Protected helpers which delegate to RawMachineAssembler. |
225 Graph* graph(); | 255 Graph* graph(); |
226 Isolate* isolate(); | 256 Isolate* isolate(); |
227 Zone* zone(); | 257 Zone* zone(); |
228 | 258 |
229 // Enables subclasses to perform operations before and after a call. | 259 // Enables subclasses to perform operations before and after a call. |
230 virtual void CallPrologue(); | 260 virtual void CallPrologue(); |
231 virtual void CallEpilogue(); | 261 virtual void CallEpilogue(); |
232 | 262 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 // Map of variables to the list of value nodes that have been added from each | 302 // Map of variables to the list of value nodes that have been added from each |
273 // merge path in their order of merging. | 303 // merge path in their order of merging. |
274 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 304 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
275 }; | 305 }; |
276 | 306 |
277 } // namespace compiler | 307 } // namespace compiler |
278 } // namespace internal | 308 } // namespace internal |
279 } // namespace v8 | 309 } // namespace v8 |
280 | 310 |
281 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 311 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |