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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // Constants. | 159 // Constants. |
160 Node* Int32Constant(int value); | 160 Node* Int32Constant(int value); |
161 Node* IntPtrConstant(intptr_t value); | 161 Node* IntPtrConstant(intptr_t value); |
162 Node* NumberConstant(double value); | 162 Node* NumberConstant(double value); |
163 Node* SmiConstant(Smi* value); | 163 Node* SmiConstant(Smi* value); |
164 Node* HeapConstant(Handle<HeapObject> object); | 164 Node* HeapConstant(Handle<HeapObject> object); |
165 Node* BooleanConstant(bool value); | 165 Node* BooleanConstant(bool value); |
166 Node* ExternalConstant(ExternalReference address); | 166 Node* ExternalConstant(ExternalReference address); |
167 Node* Float64Constant(double value); | 167 Node* Float64Constant(double value); |
168 Node* BooleanMapConstant(); | 168 Node* BooleanMapConstant(); |
169 Node* EmptyStringConstant(); | |
170 Node* HeapNumberMapConstant(); | 169 Node* HeapNumberMapConstant(); |
171 Node* NaNConstant(); | |
172 Node* NoContextConstant(); | |
173 Node* NullConstant(); | 170 Node* NullConstant(); |
174 Node* UndefinedConstant(); | 171 Node* UndefinedConstant(); |
175 | 172 |
176 Node* Parameter(int value); | 173 Node* Parameter(int value); |
177 void Return(Node* value); | 174 void Return(Node* value); |
178 | 175 |
179 void Bind(Label* label); | 176 void Bind(Label* label); |
180 void Goto(Label* label); | 177 void Goto(Label* label); |
181 void GotoIf(Node* condition, Label* true_label); | 178 void GotoIf(Node* condition, Label* true_label); |
182 void GotoUnless(Node* condition, Label* false_label); | 179 void GotoUnless(Node* condition, Label* false_label); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // Float64 operations. | 275 // Float64 operations. |
279 Node* Float64Ceil(Node* x); | 276 Node* Float64Ceil(Node* x); |
280 Node* Float64Floor(Node* x); | 277 Node* Float64Floor(Node* x); |
281 Node* Float64Round(Node* x); | 278 Node* Float64Round(Node* x); |
282 Node* Float64Trunc(Node* x); | 279 Node* Float64Trunc(Node* x); |
283 | 280 |
284 // Tag a Word as a Smi value. | 281 // Tag a Word as a Smi value. |
285 Node* SmiTag(Node* value); | 282 Node* SmiTag(Node* value); |
286 // Untag a Smi value as a Word. | 283 // Untag a Smi value as a Word. |
287 Node* SmiUntag(Node* value); | 284 Node* SmiUntag(Node* value); |
288 Node* SmiToWord(Node* value) { return SmiUntag(value); } | |
289 | 285 |
290 // Smi conversions. | 286 // Smi conversions. |
291 Node* SmiToFloat64(Node* value); | 287 Node* SmiToFloat64(Node* value); |
292 Node* SmiFromWord32(Node* value); | |
293 Node* SmiToWord32(Node* value); | 288 Node* SmiToWord32(Node* value); |
294 | 289 |
295 // Smi operations. | 290 // Smi operations. |
296 Node* SmiAdd(Node* a, Node* b); | 291 Node* SmiAdd(Node* a, Node* b); |
297 Node* SmiAddWithOverflow(Node* a, Node* b); | 292 Node* SmiAddWithOverflow(Node* a, Node* b); |
298 Node* SmiSub(Node* a, Node* b); | 293 Node* SmiSub(Node* a, Node* b); |
299 Node* SmiSubWithOverflow(Node* a, Node* b); | 294 Node* SmiSubWithOverflow(Node* a, Node* b); |
300 Node* SmiEqual(Node* a, Node* b); | 295 Node* SmiEqual(Node* a, Node* b); |
301 Node* SmiAboveOrEqual(Node* a, Node* b); | |
302 Node* SmiLessThan(Node* a, Node* b); | 296 Node* SmiLessThan(Node* a, Node* b); |
303 Node* SmiLessThanOrEqual(Node* a, Node* b); | 297 Node* SmiLessThanOrEqual(Node* a, Node* b); |
304 Node* SmiMin(Node* a, Node* b); | 298 Node* SmiMin(Node* a, Node* b); |
305 | 299 |
306 // Load a value from the root array. | 300 // Load a value from the root array. |
307 Node* LoadRoot(Heap::RootListIndex root_index); | 301 Node* LoadRoot(Heap::RootListIndex root_index); |
308 | 302 |
309 // Check a value for smi-ness | 303 // Check a value for smi-ness |
310 Node* WordIsSmi(Node* a); | 304 Node* WordIsSmi(Node* a); |
311 | 305 |
312 // Check that the value is a positive smi. | 306 // Check that the value is a positive smi. |
313 Node* WordIsPositiveSmi(Node* a); | 307 Node* WordIsPositiveSmi(Node* a); |
314 | 308 |
315 // Load an object pointer from a buffer that isn't in the heap. | 309 // Load an object pointer from a buffer that isn't in the heap. |
316 Node* LoadBufferObject(Node* buffer, int offset, | 310 Node* LoadBufferObject(Node* buffer, int offset, |
317 MachineType rep = MachineType::AnyTagged()); | 311 MachineType rep = MachineType::AnyTagged()); |
318 // Load a field from an object on the heap. | 312 // Load a field from an object on the heap. |
319 Node* LoadObjectField(Node* object, int offset, | 313 Node* LoadObjectField(Node* object, int offset, |
320 MachineType rep = MachineType::AnyTagged()); | 314 MachineType rep = MachineType::AnyTagged()); |
321 // Store a field to an object on the heap. | |
322 Node* StoreObjectFieldNoWriteBarrier( | |
323 Node* object, int offset, Node* value, | |
324 MachineRepresentation rep = MachineRepresentation::kTagged); | |
325 // Load the floating point value of a HeapNumber. | 315 // Load the floating point value of a HeapNumber. |
326 Node* LoadHeapNumberValue(Node* object); | 316 Node* LoadHeapNumberValue(Node* object); |
327 // Store the floating point value of a HeapNumber. | 317 // Store the floating point value of a HeapNumber. |
328 Node* StoreHeapNumberValue(Node* object, Node* value); | 318 Node* StoreHeapNumberValue(Node* object, Node* value); |
329 // Truncate the floating point value of a HeapNumber to an Int32. | 319 // Truncate the floating point value of a HeapNumber to an Int32. |
330 Node* TruncateHeapNumberValueToWord32(Node* object); | 320 Node* TruncateHeapNumberValueToWord32(Node* object); |
331 // Load the bit field of a Map. | 321 // Load the bit field of a Map. |
332 Node* LoadMapBitField(Node* map); | 322 Node* LoadMapBitField(Node* map); |
333 // Load bit field 2 of a map. | 323 // Load bit field 2 of a map. |
334 Node* LoadMapBitField2(Node* map); | 324 Node* LoadMapBitField2(Node* map); |
335 // Load bit field 3 of a map. | 325 // Load bit field 3 of a map. |
336 Node* LoadMapBitField3(Node* map); | 326 Node* LoadMapBitField3(Node* map); |
337 // Load the instance type of a map. | 327 // Load the instance type of a map. |
338 Node* LoadMapInstanceType(Node* map); | 328 Node* LoadMapInstanceType(Node* map); |
339 // Load the instance descriptors of a map. | 329 // Load the instance descriptors of a map. |
340 Node* LoadMapDescriptors(Node* map); | 330 Node* LoadMapDescriptors(Node* map); |
341 | 331 |
342 // Load the hash field of a name. | 332 // Load the hash field of a name. |
343 Node* LoadNameHash(Node* name); | 333 Node* LoadNameHash(Node* name); |
344 | 334 |
345 // Load an array element from a FixedArray. | 335 // Load an array element from a FixedArray. |
346 Node* LoadFixedArrayElementInt32Index(Node* object, Node* int32_index, | 336 Node* LoadFixedArrayElementInt32Index(Node* object, Node* int32_index, |
347 int additional_offset = 0); | 337 int additional_offset = 0); |
348 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, | 338 Node* LoadFixedArrayElementSmiIndex(Node* object, Node* smi_index, |
349 int additional_offset = 0); | 339 int additional_offset = 0); |
350 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); | 340 Node* LoadFixedArrayElementConstantIndex(Node* object, int index); |
351 | 341 |
352 // Allocate an object of the given size. | 342 // Allocate an object of the given size. |
353 Node* Allocate(int size, AllocationFlags flags = kNone); | 343 Node* Allocate(int size, AllocationFlags flags = kNone); |
354 Node* InnerAllocate(Node* previous, int offset); | |
355 // Allocate a HeapNumber without initializing its value. | 344 // Allocate a HeapNumber without initializing its value. |
356 Node* AllocateHeapNumber(); | 345 Node* AllocateHeapNumber(); |
357 // Allocate a HeapNumber with a specific value. | 346 // Allocate a HeapNumber with a specific value. |
358 Node* AllocateHeapNumberWithValue(Node* value); | 347 Node* AllocateHeapNumberWithValue(Node* value); |
359 // Allocate a SeqOneByteString with the given length. | |
360 Node* AllocateSeqOneByteString(int length); | |
361 // Allocate a SeqTwoByteString with the given length. | |
362 Node* AllocateSeqTwoByteString(int length); | |
363 | 348 |
364 // Store an array element to a FixedArray. | 349 // Store an array element to a FixedArray. |
365 Node* StoreFixedArrayElementInt32Index(Node* object, Node* index, | |
366 Node* value); | |
367 Node* StoreFixedArrayElementNoWriteBarrier(Node* object, Node* index, | 350 Node* StoreFixedArrayElementNoWriteBarrier(Node* object, Node* index, |
368 Node* value); | 351 Node* value); |
369 // Load the Map of an HeapObject. | 352 // Load the Map of an HeapObject. |
370 Node* LoadMap(Node* object); | 353 Node* LoadMap(Node* object); |
371 // Store the Map of an HeapObject. | 354 // Store the Map of an HeapObject. |
372 Node* StoreMapNoWriteBarrier(Node* object, Node* map); | 355 Node* StoreMapNoWriteBarrier(Node* object, Node* map); |
373 // Load the instance type of an HeapObject. | 356 // Load the instance type of an HeapObject. |
374 Node* LoadInstanceType(Node* object); | 357 Node* LoadInstanceType(Node* object); |
375 | 358 |
376 // Load the elements backing store of a JSObject. | 359 // Load the elements backing store of a JSObject. |
377 Node* LoadElements(Node* object); | 360 Node* LoadElements(Node* object); |
378 // Load the length of a fixed array base instance. | 361 // Load the length of a fixed array base instance. |
379 Node* LoadFixedArrayBaseLength(Node* array); | 362 Node* LoadFixedArrayBaseLength(Node* array); |
380 | 363 |
381 // Returns a node that is true if the given bit is set in |word32|. | 364 // Returns a node that is true if the given bit is set in |word32|. |
382 template <typename T> | 365 template <typename T> |
383 Node* BitFieldDecode(Node* word32) { | 366 Node* BitFieldDecode(Node* word32) { |
384 return BitFieldDecode(word32, T::kShift, T::kMask); | 367 return BitFieldDecode(word32, T::kShift, T::kMask); |
385 } | 368 } |
386 | 369 |
387 Node* BitFieldDecode(Node* word32, uint32_t shift, uint32_t mask); | 370 Node* BitFieldDecode(Node* word32, uint32_t shift, uint32_t mask); |
388 | 371 |
389 // Conversions. | 372 // Conversions. |
390 Node* ChangeFloat64ToTagged(Node* value); | 373 Node* ChangeFloat64ToTagged(Node* value); |
391 Node* ChangeInt32ToTagged(Node* value); | 374 Node* ChangeInt32ToTagged(Node* value); |
392 Node* TruncateTaggedToFloat64(Node* context, Node* value); | 375 Node* TruncateTaggedToFloat64(Node* context, Node* value); |
393 Node* TruncateTaggedToWord32(Node* context, Node* value); | 376 Node* TruncateTaggedToWord32(Node* context, Node* value); |
394 | 377 |
395 // Type conversions. | |
396 // Throws a TypeError for {method_name} if {value} is not coercible to Object, | |
397 // or returns the {value} converted to a String otherwise. | |
398 Node* ToThisString(Node* context, Node* value, char const* method_name); | |
399 | |
400 // String helpers. | |
401 // Load a character from a String (might flatten a ConsString). | |
402 Node* StringCharCodeAt(Node* string, Node* smi_index); | |
403 // Return the single character string with only {code}. | |
404 Node* StringFromCharCode(Node* code); | |
405 | |
406 // Branching helpers. | 378 // Branching helpers. |
407 // TODO(danno): Can we be more cleverish wrt. edge-split? | 379 // TODO(danno): Can we be more cleverish wrt. edge-split? |
408 void BranchIf(Node* condition, Label* if_true, Label* if_false); | 380 void BranchIf(Node* condition, Label* if_true, Label* if_false); |
409 | 381 |
410 #define BRANCH_HELPER(name) \ | 382 #define BRANCH_HELPER(name) \ |
411 void BranchIf##name(Node* a, Node* b, Label* if_true, Label* if_false) { \ | 383 void BranchIf##name(Node* a, Node* b, Label* if_true, Label* if_false) { \ |
412 BranchIf(name(a, b), if_true, if_false); \ | 384 BranchIf(name(a, b), if_true, if_false); \ |
413 } | 385 } |
414 CODE_STUB_ASSEMBLER_COMPARE_BINARY_OP_LIST(BRANCH_HELPER) | 386 CODE_STUB_ASSEMBLER_COMPARE_BINARY_OP_LIST(BRANCH_HELPER) |
415 #undef BRANCH_HELPER | 387 #undef BRANCH_HELPER |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // Map of variables to the list of value nodes that have been added from each | 475 // Map of variables to the list of value nodes that have been added from each |
504 // merge path in their order of merging. | 476 // merge path in their order of merging. |
505 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; | 477 std::map<Variable::Impl*, std::vector<Node*>> variable_merges_; |
506 }; | 478 }; |
507 | 479 |
508 } // namespace compiler | 480 } // namespace compiler |
509 } // namespace internal | 481 } // namespace internal |
510 } // namespace v8 | 482 } // namespace v8 |
511 | 483 |
512 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ | 484 #endif // V8_COMPILER_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |