| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_CODE_STUB_ASSEMBLER_H_ | 5 #ifndef V8_CODE_STUB_ASSEMBLER_H_ |
| 6 #define V8_CODE_STUB_ASSEMBLER_H_ | 6 #define V8_CODE_STUB_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "src/compiler/code-assembler.h" | 10 #include "src/compiler/code-assembler.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 compiler::Node* SmiFromWord32(compiler::Node* value); | 104 compiler::Node* SmiFromWord32(compiler::Node* value); |
| 105 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } | 105 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } |
| 106 compiler::Node* SmiToWord32(compiler::Node* value); | 106 compiler::Node* SmiToWord32(compiler::Node* value); |
| 107 | 107 |
| 108 // Smi operations. | 108 // Smi operations. |
| 109 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); | 109 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); |
| 110 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); | 110 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); |
| 111 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); | 111 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); |
| 112 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); | 112 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); |
| 113 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); | 113 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); |
| 114 compiler::Node* SmiAbove(compiler::Node* a, compiler::Node* b); | |
| 115 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); | 114 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); |
| 116 compiler::Node* SmiBelow(compiler::Node* a, compiler::Node* b); | |
| 117 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); | 115 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); |
| 118 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); | 116 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); |
| 119 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); | 117 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
| 120 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 118 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
| 121 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); | 119 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); |
| 122 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 120 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
| 123 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); | 121 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); |
| 124 | 122 |
| 125 // Allocate an object of the given size. | 123 // Allocate an object of the given size. |
| 126 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); | 124 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
| 127 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); | 125 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
| 128 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); | 126 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
| 129 compiler::Node* InnerAllocate(compiler::Node* previous, | 127 compiler::Node* InnerAllocate(compiler::Node* previous, |
| 130 compiler::Node* offset); | 128 compiler::Node* offset); |
| 131 | 129 |
| 132 void Assert(compiler::Node* condition); | 130 void Assert(compiler::Node* condition); |
| 133 | 131 |
| 134 // Check a value for smi-ness | 132 // Check a value for smi-ness |
| 135 compiler::Node* WordIsSmi(compiler::Node* a); | 133 compiler::Node* WordIsSmi(compiler::Node* a); |
| 136 // Check that the value is a non-negative smi. | 134 // Check that the value is a positive smi. |
| 137 compiler::Node* WordIsPositiveSmi(compiler::Node* a); | 135 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
| 138 // Check that the value is a negative smi. | |
| 139 compiler::Node* WordIsNotPositiveSmi(compiler::Node* a); | |
| 140 | 136 |
| 141 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, | 137 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, |
| 142 Label* if_false) { | 138 Label* if_false) { |
| 143 BranchIf(SmiEqual(a, b), if_true, if_false); | 139 BranchIf(SmiEqual(a, b), if_true, if_false); |
| 144 } | 140 } |
| 145 | 141 |
| 146 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, | 142 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, |
| 147 Label* if_false) { | 143 Label* if_false) { |
| 148 BranchIf(SmiLessThan(a, b), if_true, if_false); | 144 BranchIf(SmiLessThan(a, b), if_true, if_false); |
| 149 } | 145 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, | 315 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, |
| 320 MutableMode mode = IMMUTABLE); | 316 MutableMode mode = IMMUTABLE); |
| 321 // Allocate a SeqOneByteString with the given length. | 317 // Allocate a SeqOneByteString with the given length. |
| 322 compiler::Node* AllocateSeqOneByteString(int length); | 318 compiler::Node* AllocateSeqOneByteString(int length); |
| 323 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, | 319 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, |
| 324 compiler::Node* length); | 320 compiler::Node* length); |
| 325 // Allocate a SeqTwoByteString with the given length. | 321 // Allocate a SeqTwoByteString with the given length. |
| 326 compiler::Node* AllocateSeqTwoByteString(int length); | 322 compiler::Node* AllocateSeqTwoByteString(int length); |
| 327 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, | 323 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, |
| 328 compiler::Node* length); | 324 compiler::Node* length); |
| 329 | |
| 330 // Allocate a SlicedOneByteString with the given length, parent and offset. | |
| 331 // |length| and |offset| are expected to be tagged. | |
| 332 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, | |
| 333 compiler::Node* parent, | |
| 334 compiler::Node* offset); | |
| 335 // Allocate a SlicedTwoByteString with the given length, parent and offset. | |
| 336 // |length| and |offset| are expected to be tagged. | |
| 337 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, | |
| 338 compiler::Node* parent, | |
| 339 compiler::Node* offset); | |
| 340 | |
| 341 // Allocate a JSArray without elements and initialize the header fields. | 325 // Allocate a JSArray without elements and initialize the header fields. |
| 342 compiler::Node* AllocateUninitializedJSArrayWithoutElements( | 326 compiler::Node* AllocateUninitializedJSArrayWithoutElements( |
| 343 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 327 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
| 344 compiler::Node* allocation_site); | 328 compiler::Node* allocation_site); |
| 345 // Allocate and return a JSArray with initialized header fields and its | 329 // Allocate and return a JSArray with initialized header fields and its |
| 346 // uninitialized elements. | 330 // uninitialized elements. |
| 347 // The ParameterMode argument is only used for the capacity parameter. | 331 // The ParameterMode argument is only used for the capacity parameter. |
| 348 std::pair<compiler::Node*, compiler::Node*> | 332 std::pair<compiler::Node*, compiler::Node*> |
| 349 AllocateUninitializedJSArrayWithElements( | 333 AllocateUninitializedJSArrayWithElements( |
| 350 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 334 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 381 | 365 |
| 382 // Copies |element_count| elements from |from_array| to |to_array| of | 366 // Copies |element_count| elements from |from_array| to |to_array| of |
| 383 // |capacity| size respecting both array's elements kinds. | 367 // |capacity| size respecting both array's elements kinds. |
| 384 void CopyFixedArrayElements( | 368 void CopyFixedArrayElements( |
| 385 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, | 369 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, |
| 386 compiler::Node* to_array, compiler::Node* element_count, | 370 compiler::Node* to_array, compiler::Node* element_count, |
| 387 compiler::Node* capacity, | 371 compiler::Node* capacity, |
| 388 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 372 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| 389 ParameterMode mode = INTEGER_PARAMETERS); | 373 ParameterMode mode = INTEGER_PARAMETERS); |
| 390 | 374 |
| 391 // Copies |character_count| elements from |from_string| to |to_string| | |
| 392 // starting at the |from_index|'th character. |from_index| and | |
| 393 // |character_count| must be Smis s.t. | |
| 394 // 0 <= |from_index| <= |from_index| + |character_count| < from_string.length. | |
| 395 void CopyStringCharacters(compiler::Node* from_string, | |
| 396 compiler::Node* to_string, | |
| 397 compiler::Node* from_index, | |
| 398 compiler::Node* character_count, | |
| 399 String::Encoding encoding); | |
| 400 | |
| 401 // Loads an element from |array| of |from_kind| elements by given |offset| | 375 // Loads an element from |array| of |from_kind| elements by given |offset| |
| 402 // (NOTE: not index!), does a hole check if |if_hole| is provided and | 376 // (NOTE: not index!), does a hole check if |if_hole| is provided and |
| 403 // converts the value so that it becomes ready for storing to array of | 377 // converts the value so that it becomes ready for storing to array of |
| 404 // |to_kind| elements. | 378 // |to_kind| elements. |
| 405 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, | 379 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, |
| 406 compiler::Node* offset, | 380 compiler::Node* offset, |
| 407 ElementsKind from_kind, | 381 ElementsKind from_kind, |
| 408 ElementsKind to_kind, | 382 ElementsKind to_kind, |
| 409 Label* if_hole); | 383 Label* if_hole); |
| 410 | 384 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, | 436 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, |
| 463 PrimitiveType primitive_type, | 437 PrimitiveType primitive_type, |
| 464 char const* method_name); | 438 char const* method_name); |
| 465 | 439 |
| 466 // String helpers. | 440 // String helpers. |
| 467 // Load a character from a String (might flatten a ConsString). | 441 // Load a character from a String (might flatten a ConsString). |
| 468 compiler::Node* StringCharCodeAt(compiler::Node* string, | 442 compiler::Node* StringCharCodeAt(compiler::Node* string, |
| 469 compiler::Node* smi_index); | 443 compiler::Node* smi_index); |
| 470 // Return the single character string with only {code}. | 444 // Return the single character string with only {code}. |
| 471 compiler::Node* StringFromCharCode(compiler::Node* code); | 445 compiler::Node* StringFromCharCode(compiler::Node* code); |
| 472 // Return a new string object which holds a substring containing the range | |
| 473 // [from,to[ of string. |from| and |to| are expected to be tagged. | |
| 474 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, | |
| 475 compiler::Node* from, compiler::Node* to); | |
| 476 | 446 |
| 477 // Type conversion helpers. | 447 // Type conversion helpers. |
| 478 // Convert a String to a Number. | 448 // Convert a String to a Number. |
| 479 compiler::Node* StringToNumber(compiler::Node* context, | 449 compiler::Node* StringToNumber(compiler::Node* context, |
| 480 compiler::Node* input); | 450 compiler::Node* input); |
| 481 // Convert an object to a name. | 451 // Convert an object to a name. |
| 482 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); | 452 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); |
| 483 // Convert a Non-Number object to a Number. | 453 // Convert a Non-Number object to a Number. |
| 484 compiler::Node* NonNumberToNumber(compiler::Node* context, | 454 compiler::Node* NonNumberToNumber(compiler::Node* context, |
| 485 compiler::Node* input); | 455 compiler::Node* input); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 Label* bailout); | 797 Label* bailout); |
| 828 | 798 |
| 829 static const int kElementLoopUnrollThreshold = 8; | 799 static const int kElementLoopUnrollThreshold = 8; |
| 830 }; | 800 }; |
| 831 | 801 |
| 832 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 802 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
| 833 | 803 |
| 834 } // namespace internal | 804 } // namespace internal |
| 835 } // namespace v8 | 805 } // namespace v8 |
| 836 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 806 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
| OLD | NEW |