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

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

Issue 2435953002: Add CodeStubAssembler::FlattenString (Closed)
Patch Set: deferred block Created 4 years, 2 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') | test/cctest/test-code-stub-assembler.cc » ('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 f23b82829ecc3d8dbc81cf1a7622977a6a67bdca..936248cc5e89cb748e19e138105f0189d59f6a04 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -3619,6 +3619,44 @@ Node* CodeStubAssembler::ToString(Node* context, Node* input) {
return result.value();
}
+Node* CodeStubAssembler::FlattenString(Node* string) {
+ Variable var_result(this, MachineRepresentation::kTagged);
+ var_result.Bind(string);
+
+ Node* instance_type = LoadInstanceType(string);
+
+ // Check if the {string} is not a ConsString (i.e. already flat).
+ Label is_cons(this, Label::kDeferred), is_flat_in_cons(this), end(this);
+ {
+ GotoUnless(Word32Equal(Word32And(instance_type,
+ Int32Constant(kStringRepresentationMask)),
+ Int32Constant(kConsStringTag)),
+ &end);
+
+ // Check whether the right hand side is the empty string (i.e. if
+ // this is really a flat string in a cons string).
+ Node* rhs = LoadObjectField(string, ConsString::kSecondOffset);
+ Branch(WordEqual(rhs, EmptyStringConstant()), &is_flat_in_cons, &is_cons);
+ }
+
+ // Bail out to the runtime.
+ Bind(&is_cons);
+ {
+ var_result.Bind(
+ CallRuntime(Runtime::kFlattenString, NoContextConstant(), string));
+ Goto(&end);
+ }
+
+ Bind(&is_flat_in_cons);
+ {
+ var_result.Bind(LoadObjectField(string, ConsString::kFirstOffset));
+ Goto(&end);
+ }
+
+ Bind(&end);
+ return var_result.value();
+}
+
Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) {
STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE);
Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this);
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698