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 #include "src/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 Node* result = AllocateHeapNumber(); | 625 Node* result = AllocateHeapNumber(); |
626 StoreHeapNumberValue(result, value); | 626 StoreHeapNumberValue(result, value); |
627 return result; | 627 return result; |
628 } | 628 } |
629 | 629 |
630 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) { | 630 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) { |
631 Node* result = Allocate(SeqOneByteString::SizeFor(length)); | 631 Node* result = Allocate(SeqOneByteString::SizeFor(length)); |
632 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); | 632 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); |
633 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, | 633 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, |
634 SmiConstant(Smi::FromInt(length))); | 634 SmiConstant(Smi::FromInt(length))); |
635 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, | 635 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, |
636 IntPtrConstant(String::kEmptyHashField)); | 636 IntPtrConstant(String::kEmptyHashField)); |
637 return result; | 637 return result; |
638 } | 638 } |
639 | 639 |
640 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length) { | 640 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length) { |
641 Variable var_result(this, MachineRepresentation::kTagged); | 641 Variable var_result(this, MachineRepresentation::kTagged); |
642 | 642 |
643 // Compute the SeqOneByteString size and check if it fits into new space. | 643 // Compute the SeqOneByteString size and check if it fits into new space. |
644 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), | 644 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), |
645 if_join(this); | 645 if_join(this); |
646 Node* size = WordAnd( | 646 Node* size = WordAnd( |
647 IntPtrAdd( | 647 IntPtrAdd( |
648 IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)), | 648 IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)), |
649 IntPtrConstant(kObjectAlignmentMask)), | 649 IntPtrConstant(kObjectAlignmentMask)), |
650 IntPtrConstant(~kObjectAlignmentMask)); | 650 IntPtrConstant(~kObjectAlignmentMask)); |
651 Branch(IntPtrLessThanOrEqual(size, | 651 Branch(IntPtrLessThanOrEqual(size, |
652 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), | 652 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), |
653 &if_sizeissmall, &if_notsizeissmall); | 653 &if_sizeissmall, &if_notsizeissmall); |
654 | 654 |
655 Bind(&if_sizeissmall); | 655 Bind(&if_sizeissmall); |
656 { | 656 { |
657 // Just allocate the SeqOneByteString in new space. | 657 // Just allocate the SeqOneByteString in new space. |
658 Node* result = Allocate(size); | 658 Node* result = Allocate(size); |
659 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); | 659 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); |
660 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, | 660 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, |
661 SmiFromWord(length)); | 661 SmiFromWord(length)); |
662 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, | 662 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, |
663 IntPtrConstant(String::kEmptyHashField)); | 663 IntPtrConstant(String::kEmptyHashField)); |
664 var_result.Bind(result); | 664 var_result.Bind(result); |
665 Goto(&if_join); | 665 Goto(&if_join); |
666 } | 666 } |
667 | 667 |
668 Bind(&if_notsizeissmall); | 668 Bind(&if_notsizeissmall); |
669 { | 669 { |
670 // We might need to allocate in large object space, go to the runtime. | 670 // We might need to allocate in large object space, go to the runtime. |
671 Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context, | 671 Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context, |
672 SmiFromWord(length)); | 672 SmiFromWord(length)); |
673 var_result.Bind(result); | 673 var_result.Bind(result); |
674 Goto(&if_join); | 674 Goto(&if_join); |
675 } | 675 } |
676 | 676 |
677 Bind(&if_join); | 677 Bind(&if_join); |
678 return var_result.value(); | 678 return var_result.value(); |
679 } | 679 } |
680 | 680 |
681 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { | 681 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { |
682 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); | 682 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); |
683 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); | 683 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
684 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, | 684 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
685 SmiConstant(Smi::FromInt(length))); | 685 SmiConstant(Smi::FromInt(length))); |
686 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 686 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset, |
687 IntPtrConstant(String::kEmptyHashField)); | 687 IntPtrConstant(String::kEmptyHashField)); |
688 return result; | 688 return result; |
689 } | 689 } |
690 | 690 |
691 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) { | 691 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) { |
692 Variable var_result(this, MachineRepresentation::kTagged); | 692 Variable var_result(this, MachineRepresentation::kTagged); |
693 | 693 |
694 // Compute the SeqTwoByteString size and check if it fits into new space. | 694 // Compute the SeqTwoByteString size and check if it fits into new space. |
695 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), | 695 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), |
696 if_join(this); | 696 if_join(this); |
697 Node* size = WordAnd( | 697 Node* size = WordAnd( |
698 IntPtrAdd(IntPtrAdd(WordShl(length, 1), | 698 IntPtrAdd(IntPtrAdd(WordShl(length, 1), |
699 IntPtrConstant(SeqTwoByteString::kHeaderSize)), | 699 IntPtrConstant(SeqTwoByteString::kHeaderSize)), |
700 IntPtrConstant(kObjectAlignmentMask)), | 700 IntPtrConstant(kObjectAlignmentMask)), |
701 IntPtrConstant(~kObjectAlignmentMask)); | 701 IntPtrConstant(~kObjectAlignmentMask)); |
702 Branch(IntPtrLessThanOrEqual(size, | 702 Branch(IntPtrLessThanOrEqual(size, |
703 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), | 703 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), |
704 &if_sizeissmall, &if_notsizeissmall); | 704 &if_sizeissmall, &if_notsizeissmall); |
705 | 705 |
706 Bind(&if_sizeissmall); | 706 Bind(&if_sizeissmall); |
707 { | 707 { |
708 // Just allocate the SeqTwoByteString in new space. | 708 // Just allocate the SeqTwoByteString in new space. |
709 Node* result = Allocate(size); | 709 Node* result = Allocate(size); |
710 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); | 710 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
711 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, | 711 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
712 SmiFromWord(length)); | 712 SmiFromWord(length)); |
713 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 713 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset, |
714 IntPtrConstant(String::kEmptyHashField)); | 714 IntPtrConstant(String::kEmptyHashField)); |
715 var_result.Bind(result); | 715 var_result.Bind(result); |
716 Goto(&if_join); | 716 Goto(&if_join); |
717 } | 717 } |
718 | 718 |
719 Bind(&if_notsizeissmall); | 719 Bind(&if_notsizeissmall); |
720 { | 720 { |
721 // We might need to allocate in large object space, go to the runtime. | 721 // We might need to allocate in large object space, go to the runtime. |
722 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context, | 722 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context, |
723 SmiFromWord(length)); | 723 SmiFromWord(length)); |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 } | 1698 } |
1699 return IntPtrAdd( | 1699 return IntPtrAdd( |
1700 IntPtrConstant(base_size), | 1700 IntPtrConstant(base_size), |
1701 (element_size_shift >= 0) | 1701 (element_size_shift >= 0) |
1702 ? WordShl(index_node, IntPtrConstant(element_size_shift)) | 1702 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
1703 : WordShr(index_node, IntPtrConstant(-element_size_shift))); | 1703 : WordShr(index_node, IntPtrConstant(-element_size_shift))); |
1704 } | 1704 } |
1705 | 1705 |
1706 } // namespace internal | 1706 } // namespace internal |
1707 } // namespace v8 | 1707 } // namespace v8 |
OLD | NEW |