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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 compiler::Node* SmiFromWord32(compiler::Node* value); | 110 compiler::Node* SmiFromWord32(compiler::Node* value); |
111 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } | 111 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } |
112 compiler::Node* SmiToWord32(compiler::Node* value); | 112 compiler::Node* SmiToWord32(compiler::Node* value); |
113 | 113 |
114 // Smi operations. | 114 // Smi operations. |
115 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); | 115 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); |
116 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); | 116 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); |
117 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); | 117 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); |
118 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); | 118 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); |
119 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); | 119 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); |
| 120 compiler::Node* SmiAbove(compiler::Node* a, compiler::Node* b); |
120 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); | 121 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); |
| 122 compiler::Node* SmiBelow(compiler::Node* a, compiler::Node* b); |
121 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); | 123 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); |
122 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); | 124 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); |
123 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); | 125 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
124 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 126 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
125 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); | 127 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); |
126 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 128 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
127 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); | 129 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); |
128 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { | 130 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { |
129 return WordOr(a, b); | 131 return WordOr(a, b); |
130 } | 132 } |
131 | 133 |
132 // Allocate an object of the given size. | 134 // Allocate an object of the given size. |
133 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); | 135 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
134 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); | 136 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
135 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); | 137 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
136 compiler::Node* InnerAllocate(compiler::Node* previous, | 138 compiler::Node* InnerAllocate(compiler::Node* previous, |
137 compiler::Node* offset); | 139 compiler::Node* offset); |
138 | 140 |
139 void Assert(compiler::Node* condition); | 141 void Assert(compiler::Node* condition); |
140 | 142 |
141 // Check a value for smi-ness | 143 // Check a value for smi-ness |
142 compiler::Node* WordIsSmi(compiler::Node* a); | 144 compiler::Node* WordIsSmi(compiler::Node* a); |
143 // Check that the value is a positive smi. | 145 // Check that the value is a non-negative smi. |
144 compiler::Node* WordIsPositiveSmi(compiler::Node* a); | 146 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
145 | 147 |
146 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, | 148 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, |
147 Label* if_false) { | 149 Label* if_false) { |
148 BranchIf(SmiEqual(a, b), if_true, if_false); | 150 BranchIf(SmiEqual(a, b), if_true, if_false); |
149 } | 151 } |
150 | 152 |
151 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, | 153 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, |
152 Label* if_false) { | 154 Label* if_false) { |
153 BranchIf(SmiLessThan(a, b), if_true, if_false); | 155 BranchIf(SmiLessThan(a, b), if_true, if_false); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, | 322 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, |
321 MutableMode mode = IMMUTABLE); | 323 MutableMode mode = IMMUTABLE); |
322 // Allocate a SeqOneByteString with the given length. | 324 // Allocate a SeqOneByteString with the given length. |
323 compiler::Node* AllocateSeqOneByteString(int length); | 325 compiler::Node* AllocateSeqOneByteString(int length); |
324 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, | 326 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, |
325 compiler::Node* length); | 327 compiler::Node* length); |
326 // Allocate a SeqTwoByteString with the given length. | 328 // Allocate a SeqTwoByteString with the given length. |
327 compiler::Node* AllocateSeqTwoByteString(int length); | 329 compiler::Node* AllocateSeqTwoByteString(int length); |
328 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, | 330 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, |
329 compiler::Node* length); | 331 compiler::Node* length); |
| 332 |
| 333 // Allocate a SlicedOneByteString with the given length, parent and offset. |
| 334 // |length| and |offset| are expected to be tagged. |
| 335 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, |
| 336 compiler::Node* parent, |
| 337 compiler::Node* offset); |
| 338 // Allocate a SlicedTwoByteString with the given length, parent and offset. |
| 339 // |length| and |offset| are expected to be tagged. |
| 340 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, |
| 341 compiler::Node* parent, |
| 342 compiler::Node* offset); |
| 343 |
330 // Allocate a JSArray without elements and initialize the header fields. | 344 // Allocate a JSArray without elements and initialize the header fields. |
331 compiler::Node* AllocateUninitializedJSArrayWithoutElements( | 345 compiler::Node* AllocateUninitializedJSArrayWithoutElements( |
332 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 346 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
333 compiler::Node* allocation_site); | 347 compiler::Node* allocation_site); |
334 // Allocate and return a JSArray with initialized header fields and its | 348 // Allocate and return a JSArray with initialized header fields and its |
335 // uninitialized elements. | 349 // uninitialized elements. |
336 // The ParameterMode argument is only used for the capacity parameter. | 350 // The ParameterMode argument is only used for the capacity parameter. |
337 std::pair<compiler::Node*, compiler::Node*> | 351 std::pair<compiler::Node*, compiler::Node*> |
338 AllocateUninitializedJSArrayWithElements( | 352 AllocateUninitializedJSArrayWithElements( |
339 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 353 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
(...skipping 30 matching lines...) Expand all Loading... |
370 | 384 |
371 // Copies |element_count| elements from |from_array| to |to_array| of | 385 // Copies |element_count| elements from |from_array| to |to_array| of |
372 // |capacity| size respecting both array's elements kinds. | 386 // |capacity| size respecting both array's elements kinds. |
373 void CopyFixedArrayElements( | 387 void CopyFixedArrayElements( |
374 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, | 388 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, |
375 compiler::Node* to_array, compiler::Node* element_count, | 389 compiler::Node* to_array, compiler::Node* element_count, |
376 compiler::Node* capacity, | 390 compiler::Node* capacity, |
377 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 391 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
378 ParameterMode mode = INTEGER_PARAMETERS); | 392 ParameterMode mode = INTEGER_PARAMETERS); |
379 | 393 |
| 394 // Copies |character_count| elements from |from_string| to |to_string| |
| 395 // starting at the |from_index|'th character. |from_index| and |
| 396 // |character_count| must be Smis s.t. |
| 397 // 0 <= |from_index| <= |from_index| + |character_count| < from_string.length. |
| 398 void CopyStringCharacters(compiler::Node* from_string, |
| 399 compiler::Node* to_string, |
| 400 compiler::Node* from_index, |
| 401 compiler::Node* character_count, |
| 402 String::Encoding encoding); |
| 403 |
380 // Loads an element from |array| of |from_kind| elements by given |offset| | 404 // Loads an element from |array| of |from_kind| elements by given |offset| |
381 // (NOTE: not index!), does a hole check if |if_hole| is provided and | 405 // (NOTE: not index!), does a hole check if |if_hole| is provided and |
382 // converts the value so that it becomes ready for storing to array of | 406 // converts the value so that it becomes ready for storing to array of |
383 // |to_kind| elements. | 407 // |to_kind| elements. |
384 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, | 408 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, |
385 compiler::Node* offset, | 409 compiler::Node* offset, |
386 ElementsKind from_kind, | 410 ElementsKind from_kind, |
387 ElementsKind to_kind, | 411 ElementsKind to_kind, |
388 Label* if_hole); | 412 Label* if_hole); |
389 | 413 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, | 465 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, |
442 PrimitiveType primitive_type, | 466 PrimitiveType primitive_type, |
443 char const* method_name); | 467 char const* method_name); |
444 | 468 |
445 // String helpers. | 469 // String helpers. |
446 // Load a character from a String (might flatten a ConsString). | 470 // Load a character from a String (might flatten a ConsString). |
447 compiler::Node* StringCharCodeAt(compiler::Node* string, | 471 compiler::Node* StringCharCodeAt(compiler::Node* string, |
448 compiler::Node* smi_index); | 472 compiler::Node* smi_index); |
449 // Return the single character string with only {code}. | 473 // Return the single character string with only {code}. |
450 compiler::Node* StringFromCharCode(compiler::Node* code); | 474 compiler::Node* StringFromCharCode(compiler::Node* code); |
| 475 // Return a new string object which holds a substring containing the range |
| 476 // [from,to[ of string. |from| and |to| are expected to be tagged. |
| 477 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, |
| 478 compiler::Node* from, compiler::Node* to); |
451 | 479 |
452 compiler::Node* StringFromCodePoint(compiler::Node* codepoint, | 480 compiler::Node* StringFromCodePoint(compiler::Node* codepoint, |
453 UnicodeEncoding encoding); | 481 UnicodeEncoding encoding); |
454 | 482 |
455 // Type conversion helpers. | 483 // Type conversion helpers. |
456 // Convert a String to a Number. | 484 // Convert a String to a Number. |
457 compiler::Node* StringToNumber(compiler::Node* context, | 485 compiler::Node* StringToNumber(compiler::Node* context, |
458 compiler::Node* input); | 486 compiler::Node* input); |
459 // Convert an object to a name. | 487 // Convert an object to a name. |
460 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); | 488 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 Label* bailout); | 862 Label* bailout); |
835 | 863 |
836 static const int kElementLoopUnrollThreshold = 8; | 864 static const int kElementLoopUnrollThreshold = 8; |
837 }; | 865 }; |
838 | 866 |
839 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 867 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
840 | 868 |
841 } // namespace internal | 869 } // namespace internal |
842 } // namespace v8 | 870 } // namespace v8 |
843 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 871 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |