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

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

Issue 2435953002: Add CodeStubAssembler::FlattenString (Closed)
Patch Set: 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..8e129d4b23e70fd772fce29d2b83a51315bd6b6d 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -3610,15 +3610,44 @@ Node* CodeStubAssembler::ToString(Node* context, Node* input) {
}
Bind(&runtime);
- {
- result.Bind(CallRuntime(Runtime::kToString, context, input));
- Goto(&done);
- }
+ result.Bind(CallRuntime(Runtime::kToString, context, input));
danno 2016/10/20 08:35:52 After our discussion, not sure if you want this wh
+ Goto(&done);
Bind(&done);
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_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);
+ GotoIf(WordEqual(rhs, EmptyStringConstant()), &is_flat_in_cons);
+
+ // Bail out to the runtime.
danno 2016/10/20 08:35:52 Make this label deferred. You can make that effici
+ 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