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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/code-factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/builtins/builtins-regexp-gen.h" 5 #include "src/builtins/builtins-regexp-gen.h"
6 #include "src/builtins/builtins-utils-gen.h" 6 #include "src/builtins/builtins-utils-gen.h"
7 #include "src/builtins/builtins.h" 7 #include "src/builtins/builtins.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/code-stub-assembler.h" 9 #include "src/code-stub-assembler.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 655
656 Bind(&if_positioninbounds); 656 Bind(&if_positioninbounds);
657 } 657 }
658 658
659 // Load the character at the {position} from the {receiver}. 659 // Load the character at the {position} from the {receiver}.
660 Node* value = StringCharCodeAt(receiver, position); 660 Node* value = StringCharCodeAt(receiver, position);
661 Node* result = SmiFromWord32(value); 661 Node* result = SmiFromWord32(value);
662 Return(result); 662 Return(result);
663 } 663 }
664 664
665 // ES6 String.prototype.concat(...args)
666 // #sec-string.prototype.concat
667 TF_BUILTIN(StringPrototypeConcat, CodeStubAssembler) {
668 CodeStubArguments arguments(
669 this, ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount)));
670 Node* receiver = arguments.GetReceiver();
671 Node* context = Parameter(BuiltinDescriptor::kContext);
672
673 // Check that {receiver} is coercible to Object and convert it to a String.
674 receiver = ToThisString(context, receiver, "String.prototype.concat");
675
676 // Concatenate all the arguments passed to this builtin.
677 Variable var_result(this, MachineRepresentation::kTagged);
678 var_result.Bind(receiver);
679 arguments.ForEach(
680 CodeStubAssembler::VariableList({&var_result}, zone()),
681 [this, context, &var_result](Node* arg) {
682 arg = CallStub(CodeFactory::ToString(isolate()), context, arg);
683 var_result.Bind(CallStub(CodeFactory::StringAdd(isolate()), context,
684 var_result.value(), arg));
685 });
686 arguments.PopAndReturn(var_result.value());
687 }
688
665 void StringBuiltinsAssembler::StringIndexOf( 689 void StringBuiltinsAssembler::StringIndexOf(
666 Node* receiver, Node* instance_type, Node* search_string, 690 Node* receiver, Node* instance_type, Node* search_string,
667 Node* search_string_instance_type, Node* position, 691 Node* search_string_instance_type, Node* position,
668 std::function<void(Node*)> f_return) { 692 std::function<void(Node*)> f_return) {
669 CSA_ASSERT(this, IsString(receiver)); 693 CSA_ASSERT(this, IsString(receiver));
670 CSA_ASSERT(this, IsString(search_string)); 694 CSA_ASSERT(this, IsString(search_string));
671 CSA_ASSERT(this, TaggedIsSmi(position)); 695 CSA_ASSERT(this, TaggedIsSmi(position));
672 696
673 Label zero_length_needle(this), 697 Label zero_length_needle(this),
674 call_runtime_unchecked(this, Label::kDeferred), return_minus_1(this), 698 call_runtime_unchecked(this, Label::kDeferred), return_minus_1(this),
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context, 1634 CallRuntime(Runtime::kThrowIncompatibleMethodReceiver, context,
1611 HeapConstant(factory()->NewStringFromAsciiChecked( 1635 HeapConstant(factory()->NewStringFromAsciiChecked(
1612 "String Iterator.prototype.next", TENURED)), 1636 "String Iterator.prototype.next", TENURED)),
1613 iterator); 1637 iterator);
1614 Unreachable(); 1638 Unreachable();
1615 } 1639 }
1616 } 1640 }
1617 1641
1618 } // namespace internal 1642 } // namespace internal
1619 } // namespace v8 1643 } // namespace v8
OLDNEW
« 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