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

Unified Diff: src/code-stub-assembler.cc

Issue 2021143003: [builtins] Migrate String.fromCharCode to TurboFan code stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 53f52b504d6eef27da6d564f5dfee2e5e32071c6..9aa67811cd6733900a64535e097cdee9448d6fe8 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -637,6 +637,47 @@ Node* CodeStubAssembler::AllocateSeqOneByteString(int length) {
return result;
}
+Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length) {
+ Variable var_result(this, MachineRepresentation::kTagged);
+
+ // Compute the SeqOneByteString size and check if it fits into new space.
+ Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred),
+ if_join(this);
+ Node* size = WordAnd(
+ IntPtrAdd(
+ IntPtrAdd(length, IntPtrConstant(SeqOneByteString::kHeaderSize)),
+ IntPtrConstant(kObjectAlignmentMask)),
+ IntPtrConstant(~kObjectAlignmentMask));
+ Branch(IntPtrLessThanOrEqual(size,
+ IntPtrConstant(Page::kMaxRegularHeapObjectSize)),
+ &if_sizeissmall, &if_notsizeissmall);
+
+ Bind(&if_sizeissmall);
+ {
+ // Just allocate the SeqOneByteString in new space.
+ Node* result = Allocate(size);
+ StoreMapNoWriteBarrier(result, LoadRoot(Heap::kOneByteStringMapRootIndex));
+ StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kLengthOffset,
+ SmiFromWord(length));
+ StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot,
+ IntPtrConstant(String::kEmptyHashField));
+ var_result.Bind(result);
+ Goto(&if_join);
+ }
+
+ Bind(&if_notsizeissmall);
+ {
+ // We might need to allocate in large object space, go to the runtime.
+ Node* result = CallRuntime(Runtime::kAllocateSeqOneByteString, context,
+ SmiFromWord(length));
+ var_result.Bind(result);
+ Goto(&if_join);
+ }
+
+ Bind(&if_join);
+ return var_result.value();
+}
+
Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) {
Node* result = Allocate(SeqTwoByteString::SizeFor(length));
StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex));
@@ -647,6 +688,47 @@ Node* CodeStubAssembler::AllocateSeqTwoByteString(int length) {
return result;
}
+Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) {
+ Variable var_result(this, MachineRepresentation::kTagged);
+
+ // Compute the SeqTwoByteString size and check if it fits into new space.
+ Label if_sizeissmall(this), if_notsizeissmall(this, Label::kDeferred),
+ if_join(this);
+ Node* size = WordAnd(
+ IntPtrAdd(IntPtrAdd(WordShl(length, 1),
+ IntPtrConstant(SeqTwoByteString::kHeaderSize)),
+ IntPtrConstant(kObjectAlignmentMask)),
+ IntPtrConstant(~kObjectAlignmentMask));
+ Branch(IntPtrLessThanOrEqual(size,
+ IntPtrConstant(Page::kMaxRegularHeapObjectSize)),
+ &if_sizeissmall, &if_notsizeissmall);
+
+ Bind(&if_sizeissmall);
+ {
+ // Just allocate the SeqTwoByteString in new space.
+ Node* result = Allocate(size);
+ StoreMapNoWriteBarrier(result, LoadRoot(Heap::kStringMapRootIndex));
+ StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kLengthOffset,
+ SmiFromWord(length));
+ StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot,
+ IntPtrConstant(String::kEmptyHashField));
+ var_result.Bind(result);
+ Goto(&if_join);
+ }
+
+ Bind(&if_notsizeissmall);
+ {
+ // We might need to allocate in large object space, go to the runtime.
+ Node* result = CallRuntime(Runtime::kAllocateSeqTwoByteString, context,
+ SmiFromWord(length));
+ var_result.Bind(result);
+ Goto(&if_join);
+ }
+
+ Bind(&if_join);
+ return var_result.value();
+}
+
Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
Node* capacity_node, Node* length_node,
compiler::Node* allocation_site,
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698