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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 compiler::Node* SmiFromWord32(compiler::Node* value); | 122 compiler::Node* SmiFromWord32(compiler::Node* value); |
123 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } | 123 compiler::Node* SmiToWord(compiler::Node* value) { return SmiUntag(value); } |
124 compiler::Node* SmiToWord32(compiler::Node* value); | 124 compiler::Node* SmiToWord32(compiler::Node* value); |
125 | 125 |
126 // Smi operations. | 126 // Smi operations. |
127 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); | 127 compiler::Node* SmiAdd(compiler::Node* a, compiler::Node* b); |
128 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); | 128 compiler::Node* SmiAddWithOverflow(compiler::Node* a, compiler::Node* b); |
129 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); | 129 compiler::Node* SmiSub(compiler::Node* a, compiler::Node* b); |
130 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); | 130 compiler::Node* SmiSubWithOverflow(compiler::Node* a, compiler::Node* b); |
131 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); | 131 compiler::Node* SmiEqual(compiler::Node* a, compiler::Node* b); |
132 compiler::Node* SmiAbove(compiler::Node* a, compiler::Node* b); | |
133 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); | 132 compiler::Node* SmiAboveOrEqual(compiler::Node* a, compiler::Node* b); |
134 compiler::Node* SmiBelow(compiler::Node* a, compiler::Node* b); | |
135 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); | 133 compiler::Node* SmiLessThan(compiler::Node* a, compiler::Node* b); |
136 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); | 134 compiler::Node* SmiLessThanOrEqual(compiler::Node* a, compiler::Node* b); |
137 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); | 135 compiler::Node* SmiMin(compiler::Node* a, compiler::Node* b); |
138 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. | 136 // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
139 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); | 137 compiler::Node* SmiMod(compiler::Node* a, compiler::Node* b); |
140 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. | 138 // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
141 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); | 139 compiler::Node* SmiMul(compiler::Node* a, compiler::Node* b); |
142 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { | 140 compiler::Node* SmiOr(compiler::Node* a, compiler::Node* b) { |
143 return WordOr(a, b); | 141 return WordOr(a, b); |
144 } | 142 } |
145 | 143 |
146 // Allocate an object of the given size. | 144 // Allocate an object of the given size. |
147 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); | 145 compiler::Node* Allocate(compiler::Node* size, AllocationFlags flags = kNone); |
148 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); | 146 compiler::Node* Allocate(int size, AllocationFlags flags = kNone); |
149 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); | 147 compiler::Node* InnerAllocate(compiler::Node* previous, int offset); |
150 compiler::Node* InnerAllocate(compiler::Node* previous, | 148 compiler::Node* InnerAllocate(compiler::Node* previous, |
151 compiler::Node* offset); | 149 compiler::Node* offset); |
152 | 150 |
153 void Assert(compiler::Node* condition); | 151 void Assert(compiler::Node* condition); |
154 | 152 |
155 // Check a value for smi-ness | 153 // Check a value for smi-ness |
156 compiler::Node* WordIsSmi(compiler::Node* a); | 154 compiler::Node* WordIsSmi(compiler::Node* a); |
157 // Check that the value is a non-negative smi. | 155 // Check that the value is a positive smi. |
158 compiler::Node* WordIsPositiveSmi(compiler::Node* a); | 156 compiler::Node* WordIsPositiveSmi(compiler::Node* a); |
159 // Check that the value is a negative smi. | |
160 compiler::Node* WordIsNotPositiveSmi(compiler::Node* a); | |
161 | 157 |
162 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, | 158 void BranchIfSmiEqual(compiler::Node* a, compiler::Node* b, Label* if_true, |
163 Label* if_false) { | 159 Label* if_false) { |
164 BranchIf(SmiEqual(a, b), if_true, if_false); | 160 BranchIf(SmiEqual(a, b), if_true, if_false); |
165 } | 161 } |
166 | 162 |
167 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, | 163 void BranchIfSmiLessThan(compiler::Node* a, compiler::Node* b, Label* if_true, |
168 Label* if_false) { | 164 Label* if_false) { |
169 BranchIf(SmiLessThan(a, b), if_true, if_false); | 165 BranchIf(SmiLessThan(a, b), if_true, if_false); |
170 } | 166 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, | 336 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, |
341 MutableMode mode = IMMUTABLE); | 337 MutableMode mode = IMMUTABLE); |
342 // Allocate a SeqOneByteString with the given length. | 338 // Allocate a SeqOneByteString with the given length. |
343 compiler::Node* AllocateSeqOneByteString(int length); | 339 compiler::Node* AllocateSeqOneByteString(int length); |
344 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, | 340 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, |
345 compiler::Node* length); | 341 compiler::Node* length); |
346 // Allocate a SeqTwoByteString with the given length. | 342 // Allocate a SeqTwoByteString with the given length. |
347 compiler::Node* AllocateSeqTwoByteString(int length); | 343 compiler::Node* AllocateSeqTwoByteString(int length); |
348 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, | 344 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, |
349 compiler::Node* length); | 345 compiler::Node* length); |
350 | |
351 // Allocate a SlicedOneByteString with the given length, parent and offset. | |
352 // |length| and |offset| are expected to be tagged. | |
353 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, | |
354 compiler::Node* parent, | |
355 compiler::Node* offset); | |
356 // Allocate a SlicedTwoByteString with the given length, parent and offset. | |
357 // |length| and |offset| are expected to be tagged. | |
358 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, | |
359 compiler::Node* parent, | |
360 compiler::Node* offset); | |
361 | |
362 // Allocate a JSArray without elements and initialize the header fields. | 346 // Allocate a JSArray without elements and initialize the header fields. |
363 compiler::Node* AllocateUninitializedJSArrayWithoutElements( | 347 compiler::Node* AllocateUninitializedJSArrayWithoutElements( |
364 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 348 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
365 compiler::Node* allocation_site); | 349 compiler::Node* allocation_site); |
366 // Allocate and return a JSArray with initialized header fields and its | 350 // Allocate and return a JSArray with initialized header fields and its |
367 // uninitialized elements. | 351 // uninitialized elements. |
368 // The ParameterMode argument is only used for the capacity parameter. | 352 // The ParameterMode argument is only used for the capacity parameter. |
369 std::pair<compiler::Node*, compiler::Node*> | 353 std::pair<compiler::Node*, compiler::Node*> |
370 AllocateUninitializedJSArrayWithElements( | 354 AllocateUninitializedJSArrayWithElements( |
371 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, | 355 ElementsKind kind, compiler::Node* array_map, compiler::Node* length, |
(...skipping 30 matching lines...) Expand all Loading... |
402 | 386 |
403 // Copies |element_count| elements from |from_array| to |to_array| of | 387 // Copies |element_count| elements from |from_array| to |to_array| of |
404 // |capacity| size respecting both array's elements kinds. | 388 // |capacity| size respecting both array's elements kinds. |
405 void CopyFixedArrayElements( | 389 void CopyFixedArrayElements( |
406 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, | 390 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, |
407 compiler::Node* to_array, compiler::Node* element_count, | 391 compiler::Node* to_array, compiler::Node* element_count, |
408 compiler::Node* capacity, | 392 compiler::Node* capacity, |
409 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 393 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
410 ParameterMode mode = INTEGER_PARAMETERS); | 394 ParameterMode mode = INTEGER_PARAMETERS); |
411 | 395 |
412 // Copies |character_count| elements from |from_string| to |to_string| | |
413 // starting at the |from_index|'th character. |from_index| and | |
414 // |character_count| must be Smis s.t. | |
415 // 0 <= |from_index| <= |from_index| + |character_count| < from_string.length. | |
416 void CopyStringCharacters(compiler::Node* from_string, | |
417 compiler::Node* to_string, | |
418 compiler::Node* from_index, | |
419 compiler::Node* character_count, | |
420 String::Encoding encoding); | |
421 | |
422 // Loads an element from |array| of |from_kind| elements by given |offset| | 396 // Loads an element from |array| of |from_kind| elements by given |offset| |
423 // (NOTE: not index!), does a hole check if |if_hole| is provided and | 397 // (NOTE: not index!), does a hole check if |if_hole| is provided and |
424 // converts the value so that it becomes ready for storing to array of | 398 // converts the value so that it becomes ready for storing to array of |
425 // |to_kind| elements. | 399 // |to_kind| elements. |
426 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, | 400 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, |
427 compiler::Node* offset, | 401 compiler::Node* offset, |
428 ElementsKind from_kind, | 402 ElementsKind from_kind, |
429 ElementsKind to_kind, | 403 ElementsKind to_kind, |
430 Label* if_hole); | 404 Label* if_hole); |
431 | 405 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, | 457 compiler::Node* ToThisValue(compiler::Node* context, compiler::Node* value, |
484 PrimitiveType primitive_type, | 458 PrimitiveType primitive_type, |
485 char const* method_name); | 459 char const* method_name); |
486 | 460 |
487 // String helpers. | 461 // String helpers. |
488 // Load a character from a String (might flatten a ConsString). | 462 // Load a character from a String (might flatten a ConsString). |
489 compiler::Node* StringCharCodeAt(compiler::Node* string, | 463 compiler::Node* StringCharCodeAt(compiler::Node* string, |
490 compiler::Node* smi_index); | 464 compiler::Node* smi_index); |
491 // Return the single character string with only {code}. | 465 // Return the single character string with only {code}. |
492 compiler::Node* StringFromCharCode(compiler::Node* code); | 466 compiler::Node* StringFromCharCode(compiler::Node* code); |
493 // Return a new string object which holds a substring containing the range | |
494 // [from,to[ of string. |from| and |to| are expected to be tagged. | |
495 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, | |
496 compiler::Node* from, compiler::Node* to); | |
497 | 467 |
498 // Type conversion helpers. | 468 // Type conversion helpers. |
499 // Convert a String to a Number. | 469 // Convert a String to a Number. |
500 compiler::Node* StringToNumber(compiler::Node* context, | 470 compiler::Node* StringToNumber(compiler::Node* context, |
501 compiler::Node* input); | 471 compiler::Node* input); |
502 // Convert an object to a name. | 472 // Convert an object to a name. |
503 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); | 473 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); |
504 // Convert a Non-Number object to a Number. | 474 // Convert a Non-Number object to a Number. |
505 compiler::Node* NonNumberToNumber(compiler::Node* context, | 475 compiler::Node* NonNumberToNumber(compiler::Node* context, |
506 compiler::Node* input); | 476 compiler::Node* input); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 Label* bailout); | 837 Label* bailout); |
868 | 838 |
869 static const int kElementLoopUnrollThreshold = 8; | 839 static const int kElementLoopUnrollThreshold = 8; |
870 }; | 840 }; |
871 | 841 |
872 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 842 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
873 | 843 |
874 } // namespace internal | 844 } // namespace internal |
875 } // namespace v8 | 845 } // namespace v8 |
876 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 846 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |