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