Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2095003003: [compiler] Fix turbofan string allocation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/stub-cache.h" 9 #include "src/ic/stub-cache.h"
10 10
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 StoreHeapNumberValue(result, value); 688 StoreHeapNumberValue(result, value);
689 return result; 689 return result;
690 } 690 }
691 691
692 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) { 692 Node* CodeStubAssembler::AllocateSeqOneByteString(int length) {
693 Node* result = Allocate(SeqOneByteString::SizeFor(length)); 693 Node* result = Allocate(SeqOneByteString::SizeFor(length));
694 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); 694 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex));
695 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, 695 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset,
696 SmiConstant(Smi::FromInt(length))); 696 SmiConstant(Smi::FromInt(length)));
697 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, 697 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset,
698 IntPtrConstant(String::kEmptyHashField)); 698 IntPtrConstant(String::kEmptyHashField),
699 MachineRepresentation::kWord32);
699 return result; 700 return result;
700 } 701 }
701 702
702 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length) { 703 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length) {
703 Variable var_result(this, MachineRepresentation::kTagged); 704 Variable var_result(this, MachineRepresentation::kTagged);
704 705
705 // Compute the SeqOneByteString size and check if it fits into new space. 706 // Compute the SeqOneByteString size and check if it fits into new space.
706 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), 707 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred),
707 if_join(this); 708 if_join(this);
708 Node* size = WordAnd( 709 Node* size = WordAnd(
709 IntPtrAdd( 710 IntPtrAdd(
710 IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)), 711 IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)),
711 IntPtrConstant(kObjectAlignmentMask)), 712 IntPtrConstant(kObjectAlignmentMask)),
712 IntPtrConstant(~kObjectAlignmentMask)); 713 IntPtrConstant(~kObjectAlignmentMask));
713 Branch(IntPtrLessThanOrEqual(size, 714 Branch(IntPtrLessThanOrEqual(size,
714 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), 715 IntPtrConstant(Page::kMaxRegularHeapObjectSize)),
715 &if_sizeissmall, &if_notsizeissmall); 716 &if_sizeissmall, &if_notsizeissmall);
716 717
717 Bind(&if_sizeissmall); 718 Bind(&if_sizeissmall);
718 { 719 {
719 // Just allocate the SeqOneByteString in new space. 720 // Just allocate the SeqOneByteString in new space.
720 Node* result = Allocate(size); 721 Node* result = Allocate(size);
721 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex)); 722 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex));
722 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset, 723 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset,
723 SmiFromWord(length)); 724 SmiFromWord(length));
724 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset, 725 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldOffset,
725 IntPtrConstant(String::kEmptyHashField)); 726 IntPtrConstant(String::kEmptyHashField),
727 MachineRepresentation::kWord32);
726 var_result.Bind(result); 728 var_result.Bind(result);
727 Goto(&if_join); 729 Goto(&if_join);
728 } 730 }
729 731
730 Bind(&if_notsizeissmall); 732 Bind(&if_notsizeissmall);
731 { 733 {
732 // We might need to allocate in large object space, go to the runtime. 734 // We might need to allocate in large object space, go to the runtime.
733 Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context, 735 Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context,
734 SmiFromWord(length)); 736 SmiFromWord(length));
735 var_result.Bind(result); 737 var_result.Bind(result);
736 Goto(&if_join); 738 Goto(&if_join);
737 } 739 }
738 740
739 Bind(&if_join); 741 Bind(&if_join);
740 return var_result.value(); 742 return var_result.value();
741 } 743 }
742 744
743 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) { 745 Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) {
744 Node* result = Allocate(SeqTwoByteString::SizeFor(length)); 746 Node* result = Allocate(SeqTwoByteString::SizeFor(length));
745 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); 747 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex));
746 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, 748 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset,
747 SmiConstant(Smi::FromInt(length))); 749 SmiConstant(Smi::FromInt(length)));
748 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset, 750 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset,
749 IntPtrConstant(String::kEmptyHashField)); 751 IntPtrConstant(String::kEmptyHashField),
752 MachineRepresentation::kWord32);
750 return result; 753 return result;
751 } 754 }
752 755
753 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) { 756 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) {
754 Variable var_result(this, MachineRepresentation::kTagged); 757 Variable var_result(this, MachineRepresentation::kTagged);
755 758
756 // Compute the SeqTwoByteString size and check if it fits into new space. 759 // Compute the SeqTwoByteString size and check if it fits into new space.
757 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred), 760 Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred),
758 if_join(this); 761 if_join(this);
759 Node* size = WordAnd( 762 Node* size = WordAnd(
760 IntPtrAdd(IntPtrAdd(WordShl(length, 1), 763 IntPtrAdd(IntPtrAdd(WordShl(length, 1),
761 IntPtrConstant(SeqTwoByteString::kHeaderSize)), 764 IntPtrConstant(SeqTwoByteString::kHeaderSize)),
762 IntPtrConstant(kObjectAlignmentMask)), 765 IntPtrConstant(kObjectAlignmentMask)),
763 IntPtrConstant(~kObjectAlignmentMask)); 766 IntPtrConstant(~kObjectAlignmentMask));
764 Branch(IntPtrLessThanOrEqual(size, 767 Branch(IntPtrLessThanOrEqual(size,
765 IntPtrConstant(Page::kMaxRegularHeapObjectSize)), 768 IntPtrConstant(Page::kMaxRegularHeapObjectSize)),
766 &if_sizeissmall, &if_notsizeissmall); 769 &if_sizeissmall, &if_notsizeissmall);
767 770
768 Bind(&if_sizeissmall); 771 Bind(&if_sizeissmall);
769 { 772 {
770 // Just allocate the SeqTwoByteString in new space. 773 // Just allocate the SeqTwoByteString in new space.
771 Node* result = Allocate(size); 774 Node* result = Allocate(size);
772 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex)); 775 StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex));
773 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset, 776 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset,
774 SmiFromWord(length)); 777 SmiFromWord(length));
775 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset, 778 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldOffset,
776 IntPtrConstant(String::kEmptyHashField)); 779 IntPtrConstant(String::kEmptyHashField),
780 MachineRepresentation::kWord32);
777 var_result.Bind(result); 781 var_result.Bind(result);
778 Goto(&if_join); 782 Goto(&if_join);
779 } 783 }
780 784
781 Bind(&if_notsizeissmall); 785 Bind(&if_notsizeissmall);
782 { 786 {
783 // We might need to allocate in large object space, go to the runtime. 787 // We might need to allocate in large object space, go to the runtime.
784 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context, 788 Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context,
785 SmiFromWord(length)); 789 SmiFromWord(length));
786 var_result.Bind(result); 790 var_result.Bind(result);
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 } 2359 }
2356 Bind(&miss); 2360 Bind(&miss);
2357 { 2361 {
2358 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->name, p->slot, 2362 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, p->context, p->name, p->slot,
2359 p->vector); 2363 p->vector);
2360 } 2364 }
2361 } 2365 }
2362 2366
2363 } // namespace internal 2367 } // namespace internal
2364 } // namespace v8 2368 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698