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

Unified Diff: src/builtins/builtins-string-gen.cc

Issue 2766593002: [csa] Migrate String.prototype.concat to TurboFan builtin. (Closed)
Patch Set: Magical list is magic... Created 3 years, 9 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/builtins/builtins.h ('k') | src/code-factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-string-gen.cc
diff --git a/src/builtins/builtins-string-gen.cc b/src/builtins/builtins-string-gen.cc
index 8919a60e8adc7a2482c4605cb1c9b897b45126e7..c9027f5d227cc8d620b231ea8c1cf4d4795eadb2 100644
--- a/src/builtins/builtins-string-gen.cc
+++ b/src/builtins/builtins-string-gen.cc
@@ -662,6 +662,30 @@ TF_BUILTIN(StringPrototypeCharCodeAt, CodeStubAssembler) {
Return(result);
}
+// ES6 String.prototype.concat(...args)
+// #sec-string.prototype.concat
+TF_BUILTIN(StringPrototypeConcat, CodeStubAssembler) {
+ CodeStubArguments arguments(
+ this, ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount)));
+ Node* receiver = arguments.GetReceiver();
+ Node* context = Parameter(BuiltinDescriptor::kContext);
+
+ // Check that {receiver} is coercible to Object and convert it to a String.
+ receiver = ToThisString(context, receiver, "String.prototype.concat");
+
+ // Concatenate all the arguments passed to this builtin.
+ Variable var_result(this, MachineRepresentation::kTagged);
+ var_result.Bind(receiver);
+ arguments.ForEach(
+ CodeStubAssembler::VariableList({&var_result}, zone()),
+ [this, context, &var_result](Node* arg) {
+ arg = CallStub(CodeFactory::ToString(isolate()), context, arg);
+ var_result.Bind(CallStub(CodeFactory::StringAdd(isolate()), context,
+ var_result.value(), arg));
+ });
+ arguments.PopAndReturn(var_result.value());
+}
+
void StringBuiltinsAssembler::StringIndexOf(
Node* receiver, Node* instance_type, Node* search_string,
Node* search_string_instance_type, Node* position,
« no previous file with comments | « src/builtins/builtins.h ('k') | src/code-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698