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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 #define HEAP_CONSTANT_TEST(rootName, name) \ | 95 #define HEAP_CONSTANT_TEST(rootName, name) \ |
96 compiler::Node* Is##name(compiler::Node* value); | 96 compiler::Node* Is##name(compiler::Node* value); |
97 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) | 97 HEAP_CONSTANT_LIST(HEAP_CONSTANT_TEST) |
98 #undef HEAP_CONSTANT_TEST | 98 #undef HEAP_CONSTANT_TEST |
99 | 99 |
100 compiler::Node* HashSeed(); | 100 compiler::Node* HashSeed(); |
101 compiler::Node* StaleRegisterConstant(); | 101 compiler::Node* StaleRegisterConstant(); |
102 | 102 |
103 compiler::Node* IntPtrOrSmiConstant(int value, ParameterMode mode); | 103 compiler::Node* IntPtrOrSmiConstant(int value, ParameterMode mode); |
104 | 104 |
| 105 compiler::Node* IntPtrAddFoldConstants(compiler::Node* left, |
| 106 compiler::Node* right); |
| 107 compiler::Node* IntPtrSubFoldConstants(compiler::Node* left, |
| 108 compiler::Node* right); |
| 109 |
105 // Float64 operations. | 110 // Float64 operations. |
106 compiler::Node* Float64Ceil(compiler::Node* x); | 111 compiler::Node* Float64Ceil(compiler::Node* x); |
107 compiler::Node* Float64Floor(compiler::Node* x); | 112 compiler::Node* Float64Floor(compiler::Node* x); |
108 compiler::Node* Float64Round(compiler::Node* x); | 113 compiler::Node* Float64Round(compiler::Node* x); |
109 compiler::Node* Float64Trunc(compiler::Node* x); | 114 compiler::Node* Float64Trunc(compiler::Node* x); |
110 | 115 |
111 // Tag a Word as a Smi value. | 116 // Tag a Word as a Smi value. |
112 compiler::Node* SmiTag(compiler::Node* value); | 117 compiler::Node* SmiTag(compiler::Node* value); |
113 // Untag a Smi value as a Word. | 118 // Untag a Smi value as a Word. |
114 compiler::Node* SmiUntag(compiler::Node* value); | 119 compiler::Node* SmiUntag(compiler::Node* value); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 compiler::Node* StoreFixedDoubleArrayElement( | 340 compiler::Node* StoreFixedDoubleArrayElement( |
336 compiler::Node* object, compiler::Node* index, compiler::Node* value, | 341 compiler::Node* object, compiler::Node* index, compiler::Node* value, |
337 ParameterMode parameter_mode = INTEGER_PARAMETERS); | 342 ParameterMode parameter_mode = INTEGER_PARAMETERS); |
338 | 343 |
339 // Allocate a HeapNumber without initializing its value. | 344 // Allocate a HeapNumber without initializing its value. |
340 compiler::Node* AllocateHeapNumber(MutableMode mode = IMMUTABLE); | 345 compiler::Node* AllocateHeapNumber(MutableMode mode = IMMUTABLE); |
341 // Allocate a HeapNumber with a specific value. | 346 // Allocate a HeapNumber with a specific value. |
342 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, | 347 compiler::Node* AllocateHeapNumberWithValue(compiler::Node* value, |
343 MutableMode mode = IMMUTABLE); | 348 MutableMode mode = IMMUTABLE); |
344 // Allocate a SeqOneByteString with the given length. | 349 // Allocate a SeqOneByteString with the given length. |
345 compiler::Node* AllocateSeqOneByteString(int length); | 350 compiler::Node* AllocateSeqOneByteString(int length, |
346 compiler::Node* AllocateSeqOneByteString(compiler::Node* context, | 351 AllocationFlags flags = kNone); |
347 compiler::Node* length); | 352 compiler::Node* AllocateSeqOneByteString( |
| 353 compiler::Node* context, compiler::Node* length, |
| 354 ParameterMode mode = INTPTR_PARAMETERS, AllocationFlags flags = kNone); |
348 // Allocate a SeqTwoByteString with the given length. | 355 // Allocate a SeqTwoByteString with the given length. |
349 compiler::Node* AllocateSeqTwoByteString(int length); | 356 compiler::Node* AllocateSeqTwoByteString(int length, |
350 compiler::Node* AllocateSeqTwoByteString(compiler::Node* context, | 357 AllocationFlags flags = kNone); |
351 compiler::Node* length); | 358 compiler::Node* AllocateSeqTwoByteString( |
| 359 compiler::Node* context, compiler::Node* length, |
| 360 ParameterMode mode = INTPTR_PARAMETERS, AllocationFlags flags = kNone); |
352 | 361 |
353 // Allocate a SlicedOneByteString with the given length, parent and offset. | 362 // Allocate a SlicedOneByteString with the given length, parent and offset. |
354 // |length| and |offset| are expected to be tagged. | 363 // |length| and |offset| are expected to be tagged. |
355 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, | 364 compiler::Node* AllocateSlicedOneByteString(compiler::Node* length, |
356 compiler::Node* parent, | 365 compiler::Node* parent, |
357 compiler::Node* offset); | 366 compiler::Node* offset); |
358 // Allocate a SlicedTwoByteString with the given length, parent and offset. | 367 // Allocate a SlicedTwoByteString with the given length, parent and offset. |
359 // |length| and |offset| are expected to be tagged. | 368 // |length| and |offset| are expected to be tagged. |
360 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, | 369 compiler::Node* AllocateSlicedTwoByteString(compiler::Node* length, |
361 compiler::Node* parent, | 370 compiler::Node* parent, |
362 compiler::Node* offset); | 371 compiler::Node* offset); |
363 | 372 |
364 // Allocate a one-byte ConsString with the given length, first and second | 373 // Allocate a one-byte ConsString with the given length, first and second |
365 // parts. |length| is expected to be tagged, and |first| and |second| are | 374 // parts. |length| is expected to be tagged, and |first| and |second| are |
366 // expected to be one-byte strings. | 375 // expected to be one-byte strings. |
367 compiler::Node* AllocateOneByteConsString(compiler::Node* length, | 376 compiler::Node* AllocateOneByteConsString(compiler::Node* length, |
368 compiler::Node* first, | 377 compiler::Node* first, |
369 compiler::Node* second); | 378 compiler::Node* second, |
| 379 AllocationFlags flags = kNone); |
370 // Allocate a two-byte ConsString with the given length, first and second | 380 // Allocate a two-byte ConsString with the given length, first and second |
371 // parts. |length| is expected to be tagged, and |first| and |second| are | 381 // parts. |length| is expected to be tagged, and |first| and |second| are |
372 // expected to be two-byte strings. | 382 // expected to be two-byte strings. |
373 compiler::Node* AllocateTwoByteConsString(compiler::Node* length, | 383 compiler::Node* AllocateTwoByteConsString(compiler::Node* length, |
374 compiler::Node* first, | 384 compiler::Node* first, |
375 compiler::Node* second); | 385 compiler::Node* second, |
| 386 AllocationFlags flags = kNone); |
| 387 |
| 388 // Allocate an appropriate one- or two-byte ConsString with the first and |
| 389 // second parts specified by |first| and |second|. |
| 390 compiler::Node* NewConsString(compiler::Node* context, compiler::Node* length, |
| 391 compiler::Node* left, compiler::Node* right, |
| 392 AllocationFlags flags = kNone); |
376 | 393 |
377 // Allocate a RegExpResult with the given length (the number of captures, | 394 // Allocate a RegExpResult with the given length (the number of captures, |
378 // including the match itself), index (the index where the match starts), | 395 // including the match itself), index (the index where the match starts), |
379 // and input string. |length| and |index| are expected to be tagged, and | 396 // and input string. |length| and |index| are expected to be tagged, and |
380 // |input| must be a string. | 397 // |input| must be a string. |
381 compiler::Node* AllocateRegExpResult(compiler::Node* context, | 398 compiler::Node* AllocateRegExpResult(compiler::Node* context, |
382 compiler::Node* length, | 399 compiler::Node* length, |
383 compiler::Node* index, | 400 compiler::Node* index, |
384 compiler::Node* input); | 401 compiler::Node* input); |
385 | 402 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 void CopyFixedArrayElements( | 446 void CopyFixedArrayElements( |
430 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, | 447 ElementsKind from_kind, compiler::Node* from_array, ElementsKind to_kind, |
431 compiler::Node* to_array, compiler::Node* element_count, | 448 compiler::Node* to_array, compiler::Node* element_count, |
432 compiler::Node* capacity, | 449 compiler::Node* capacity, |
433 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, | 450 WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
434 ParameterMode mode = INTEGER_PARAMETERS); | 451 ParameterMode mode = INTEGER_PARAMETERS); |
435 | 452 |
436 // Copies |character_count| elements from |from_string| to |to_string| | 453 // Copies |character_count| elements from |from_string| to |to_string| |
437 // starting at the |from_index|'th character. |from_string| and |to_string| | 454 // starting at the |from_index|'th character. |from_string| and |to_string| |
438 // must be either both one-byte strings or both two-byte strings. | 455 // must be either both one-byte strings or both two-byte strings. |
439 // |from_index|, |to_index| and |character_count| must be Smis s.t. | 456 // |from_index|, |to_index| and |character_count| must be either Smis or |
440 // 0 <= |from_index| <= |from_index| + |character_count| <= from_string.length | 457 // intptr_ts depending on |mode| s.t. 0 <= |from_index| <= |from_index| + |
441 // and | 458 // |character_count| <= from_string.length and 0 <= |to_index| <= |to_index| + |
442 // 0 <= |to_index| <= |to_index| + |character_count| <= to_string.length. | 459 // |character_count| <= to_string.length. |
443 void CopyStringCharacters(compiler::Node* from_string, | 460 void CopyStringCharacters(compiler::Node* from_string, |
444 compiler::Node* to_string, | 461 compiler::Node* to_string, |
445 compiler::Node* from_index, | 462 compiler::Node* from_index, |
446 compiler::Node* to_index, | 463 compiler::Node* to_index, |
447 compiler::Node* character_count, | 464 compiler::Node* character_count, |
448 String::Encoding encoding); | 465 String::Encoding encoding, ParameterMode mode); |
449 | 466 |
450 // Loads an element from |array| of |from_kind| elements by given |offset| | 467 // Loads an element from |array| of |from_kind| elements by given |offset| |
451 // (NOTE: not index!), does a hole check if |if_hole| is provided and | 468 // (NOTE: not index!), does a hole check if |if_hole| is provided and |
452 // converts the value so that it becomes ready for storing to array of | 469 // converts the value so that it becomes ready for storing to array of |
453 // |to_kind| elements. | 470 // |to_kind| elements. |
454 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, | 471 compiler::Node* LoadElementAndPrepareForStore(compiler::Node* array, |
455 compiler::Node* offset, | 472 compiler::Node* offset, |
456 ElementsKind from_kind, | 473 ElementsKind from_kind, |
457 ElementsKind to_kind, | 474 ElementsKind to_kind, |
458 Label* if_hole); | 475 Label* if_hole); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 compiler::Node* StringCharCodeAt(compiler::Node* string, | 545 compiler::Node* StringCharCodeAt(compiler::Node* string, |
529 compiler::Node* smi_index); | 546 compiler::Node* smi_index); |
530 // Return the single character string with only {code}. | 547 // Return the single character string with only {code}. |
531 compiler::Node* StringFromCharCode(compiler::Node* code); | 548 compiler::Node* StringFromCharCode(compiler::Node* code); |
532 // Return a new string object which holds a substring containing the range | 549 // Return a new string object which holds a substring containing the range |
533 // [from,to[ of string. |from| and |to| are expected to be tagged. | 550 // [from,to[ of string. |from| and |to| are expected to be tagged. |
534 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, | 551 compiler::Node* SubString(compiler::Node* context, compiler::Node* string, |
535 compiler::Node* from, compiler::Node* to); | 552 compiler::Node* from, compiler::Node* to); |
536 | 553 |
537 // Return a new string object produced by concatenating |first| with |second|. | 554 // Return a new string object produced by concatenating |first| with |second|. |
538 compiler::Node* StringConcat(compiler::Node* context, compiler::Node* first, | 555 compiler::Node* StringAdd(compiler::Node* context, compiler::Node* first, |
539 compiler::Node* second); | 556 compiler::Node* second, |
| 557 AllocationFlags flags = kNone); |
540 | 558 |
541 // Return the first index >= {from} at which {needle_char} was found in | 559 // Return the first index >= {from} at which {needle_char} was found in |
542 // {string}, or -1 if such an index does not exist. The returned value is | 560 // {string}, or -1 if such an index does not exist. The returned value is |
543 // a Smi, {string} is expected to be a String, {needle_char} is an intptr, | 561 // a Smi, {string} is expected to be a String, {needle_char} is an intptr, |
544 // and {from} is expected to be tagged. | 562 // and {from} is expected to be tagged. |
545 compiler::Node* StringIndexOfChar(compiler::Node* context, | 563 compiler::Node* StringIndexOfChar(compiler::Node* context, |
546 compiler::Node* string, | 564 compiler::Node* string, |
547 compiler::Node* needle_char, | 565 compiler::Node* needle_char, |
548 compiler::Node* from); | 566 compiler::Node* from); |
549 | 567 |
550 compiler::Node* StringFromCodePoint(compiler::Node* codepoint, | 568 compiler::Node* StringFromCodePoint(compiler::Node* codepoint, |
551 UnicodeEncoding encoding); | 569 UnicodeEncoding encoding); |
552 | 570 |
553 // Type conversion helpers. | 571 // Type conversion helpers. |
554 // Convert a String to a Number. | 572 // Convert a String to a Number. |
555 compiler::Node* StringToNumber(compiler::Node* context, | 573 compiler::Node* StringToNumber(compiler::Node* context, |
556 compiler::Node* input); | 574 compiler::Node* input); |
557 compiler::Node* NumberToString(compiler::Node* context, | 575 compiler::Node* NumberToString(compiler::Node* context, |
558 compiler::Node* input); | 576 compiler::Node* input); |
559 // Convert an object to a name. | 577 // Convert an object to a name. |
560 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); | 578 compiler::Node* ToName(compiler::Node* context, compiler::Node* input); |
561 // Convert a Non-Number object to a Number. | 579 // Convert a Non-Number object to a Number. |
562 compiler::Node* NonNumberToNumber(compiler::Node* context, | 580 compiler::Node* NonNumberToNumber(compiler::Node* context, |
563 compiler::Node* input); | 581 compiler::Node* input); |
564 // Convert any object to a Number. | 582 // Convert any object to a Number. |
565 compiler::Node* ToNumber(compiler::Node* context, compiler::Node* input); | 583 compiler::Node* ToNumber(compiler::Node* context, compiler::Node* input); |
566 | 584 |
| 585 // Convert any object to a String. |
| 586 compiler::Node* ToString(compiler::Node* context, compiler::Node* input); |
| 587 |
| 588 // Convert any object to a Primitive. |
| 589 compiler::Node* JSReceiverToPrimitive(compiler::Node* context, |
| 590 compiler::Node* input); |
| 591 |
567 enum ToIntegerTruncationMode { | 592 enum ToIntegerTruncationMode { |
568 kNoTruncation, | 593 kNoTruncation, |
569 kTruncateMinusZero, | 594 kTruncateMinusZero, |
570 }; | 595 }; |
571 | 596 |
572 // Convert any object to an Integer. | 597 // Convert any object to an Integer. |
573 compiler::Node* ToInteger(compiler::Node* context, compiler::Node* input, | 598 compiler::Node* ToInteger(compiler::Node* context, compiler::Node* input, |
574 ToIntegerTruncationMode mode = kNoTruncation); | 599 ToIntegerTruncationMode mode = kNoTruncation); |
575 | 600 |
576 // Returns a node that contains a decoded (unsigned!) value of a bit | 601 // Returns a node that contains a decoded (unsigned!) value of a bit |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 void BuildFastFixedArrayForEach( | 908 void BuildFastFixedArrayForEach( |
884 compiler::Node* fixed_array, ElementsKind kind, | 909 compiler::Node* fixed_array, ElementsKind kind, |
885 compiler::Node* first_element_inclusive, | 910 compiler::Node* first_element_inclusive, |
886 compiler::Node* last_element_exclusive, | 911 compiler::Node* last_element_exclusive, |
887 std::function<void(CodeStubAssembler* assembler, | 912 std::function<void(CodeStubAssembler* assembler, |
888 compiler::Node* fixed_array, compiler::Node* offset)> | 913 compiler::Node* fixed_array, compiler::Node* offset)> |
889 body, | 914 body, |
890 ParameterMode mode = INTPTR_PARAMETERS, | 915 ParameterMode mode = INTPTR_PARAMETERS, |
891 ForEachDirection direction = ForEachDirection::kReverse); | 916 ForEachDirection direction = ForEachDirection::kReverse); |
892 | 917 |
| 918 compiler::Node* GetArrayAllocationSize(compiler::Node* element_count, |
| 919 ElementsKind kind, ParameterMode mode, |
| 920 int header_size) { |
| 921 return ElementOffsetFromIndex(element_count, kind, mode, header_size); |
| 922 } |
| 923 |
893 compiler::Node* GetFixedArrayAllocationSize(compiler::Node* element_count, | 924 compiler::Node* GetFixedArrayAllocationSize(compiler::Node* element_count, |
894 ElementsKind kind, | 925 ElementsKind kind, |
895 ParameterMode mode) { | 926 ParameterMode mode) { |
896 return ElementOffsetFromIndex(element_count, kind, mode, | 927 return GetArrayAllocationSize(element_count, kind, mode, |
897 FixedArray::kHeaderSize); | 928 FixedArray::kHeaderSize); |
898 } | 929 } |
899 | 930 |
900 enum RelationalComparisonMode { | 931 enum RelationalComparisonMode { |
901 kLessThan, | 932 kLessThan, |
902 kLessThanOrEqual, | 933 kLessThanOrEqual, |
903 kGreaterThan, | 934 kGreaterThan, |
904 kGreaterThanOrEqual | 935 kGreaterThanOrEqual |
905 }; | 936 }; |
906 | 937 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 static const int kElementLoopUnrollThreshold = 8; | 1022 static const int kElementLoopUnrollThreshold = 8; |
992 }; | 1023 }; |
993 | 1024 |
994 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) | 1025 #define CSA_ASSERT(x) Assert((x), #x, __FILE__, __LINE__) |
995 | 1026 |
996 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); | 1027 DEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags); |
997 | 1028 |
998 } // namespace internal | 1029 } // namespace internal |
999 } // namespace v8 | 1030 } // namespace v8 |
1000 #endif // V8_CODE_STUB_ASSEMBLER_H_ | 1031 #endif // V8_CODE_STUB_ASSEMBLER_H_ |
OLD | NEW |