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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::kHashFieldSlot, |
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) { |
| 641 Variable var_result(this, MachineRepresentation::kTagged); |
| 642 |
| 643 // Compute the SeqOneByteString size and check if it fits into new space. |
| 644 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), |
| 645 if_join(this); |
| 646 Node* size = WordAnd( |
| 647 IntPtrAdd( |
| 648 IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)), |
| 649 IntPtrConstant(kObjectAlignmentMask)), |
| 650 IntPtrConstant(~kObjectAlignmentMask)); |
| 651 Branch(IntPtrLessThanOrEqual(size, |
| 652 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), |
| 653 &if_sizeissmall, &if_notsizeissmall); |
| 654 |
| 655 Bind(&if_sizeissmall); |
| 656 { |
| 657 // Just allocate the SeqOneByteString in new space. |
| 658 Node* result = Allocate(size); |
| 659 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); |
| 660 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, |
| 661 SmiFromWord(length)); |
| 662 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, |
| 663 IntPtrConstant(String::kEmptyHashField)); |
| 664 var_result.Bind(result); |
| 665 Goto(&if_join); |
| 666 } |
| 667 |
| 668 Bind(&if_notsizeissmall); |
| 669 { |
| 670 // We might need to allocate in large object space, go to the runtime. |
| 671 Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context, |
| 672 SmiFromWord(length)); |
| 673 var_result.Bind(result); |
| 674 Goto(&if_join); |
| 675 } |
| 676 |
| 677 Bind(&if_join); |
| 678 return var_result.value(); |
| 679 } |
| 680 |
640 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { | 681 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { |
641 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); | 682 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); |
642 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); | 683 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
643 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, | 684 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
644 SmiConstant(Smi::FromInt(length))); | 685 SmiConstant(Smi::FromInt(length))); |
645 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 686 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, |
646 IntPtrConstant(String::kEmptyHashField)); | 687 IntPtrConstant(String::kEmptyHashField)); |
647 return result; | 688 return result; |
648 } | 689 } |
649 | 690 |
| 691 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) { |
| 692 Variable var_result(this, MachineRepresentation::kTagged); |
| 693 |
| 694 // Compute the SeqTwoByteString size and check if it fits into new space. |
| 695 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), |
| 696 if_join(this); |
| 697 Node* size = WordAnd( |
| 698 IntPtrAdd(IntPtrAdd(WordShl(length, 1), |
| 699 IntPtrConstant(SeqTwoByteString::kHeaderSize)), |
| 700 IntPtrConstant(kObjectAlignmentMask)), |
| 701 IntPtrConstant(~kObjectAlignmentMask)); |
| 702 Branch(IntPtrLessThanOrEqual(size, |
| 703 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), |
| 704 &if_sizeissmall, &if_notsizeissmall); |
| 705 |
| 706 Bind(&if_sizeissmall); |
| 707 { |
| 708 // Just allocate the SeqTwoByteString in new space. |
| 709 Node* result = Allocate(size); |
| 710 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); |
| 711 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, |
| 712 SmiFromWord(length)); |
| 713 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, |
| 714 IntPtrConstant(String::kEmptyHashField)); |
| 715 var_result.Bind(result); |
| 716 Goto(&if_join); |
| 717 } |
| 718 |
| 719 Bind(&if_notsizeissmall); |
| 720 { |
| 721 // We might need to allocate in large object space, go to the runtime. |
| 722 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context, |
| 723 SmiFromWord(length)); |
| 724 var_result.Bind(result); |
| 725 Goto(&if_join); |
| 726 } |
| 727 |
| 728 Bind(&if_join); |
| 729 return var_result.value(); |
| 730 } |
| 731 |
650 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, | 732 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
651 Node* capacity_node, Node* length_node, | 733 Node* capacity_node, Node* length_node, |
652 compiler::Node* allocation_site, | 734 compiler::Node* allocation_site, |
653 ParameterMode mode) { | 735 ParameterMode mode) { |
654 bool is_double = IsFastDoubleElementsKind(kind); | 736 bool is_double = IsFastDoubleElementsKind(kind); |
655 int base_size = JSArray::kSize + FixedArray::kHeaderSize; | 737 int base_size = JSArray::kSize + FixedArray::kHeaderSize; |
656 int elements_offset = JSArray::kSize; | 738 int elements_offset = JSArray::kSize; |
657 | 739 |
658 if (allocation_site != nullptr) { | 740 if (allocation_site != nullptr) { |
659 base_size += AllocationMemento::kSize; | 741 base_size += AllocationMemento::kSize; |
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 } | 1698 } |
1617 return IntPtrAdd( | 1699 return IntPtrAdd( |
1618 IntPtrConstant(base_size), | 1700 IntPtrConstant(base_size), |
1619 (element_size_shift >= 0) | 1701 (element_size_shift >= 0) |
1620 ? WordShl(index_node, IntPtrConstant(element_size_shift)) | 1702 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
1621 : WordShr(index_node, IntPtrConstant(-element_size_shift))); | 1703 : WordShr(index_node, IntPtrConstant(-element_size_shift))); |
1622 } | 1704 } |
1623 | 1705 |
1624 } // namespace internal | 1706 } // namespace internal |
1625 } // namespace v8 | 1707 } // namespace v8 |
OLD | NEW |