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

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

Issue 2667963002: [stubs] Remove StringIndexOfChar (Closed)
Patch Set: Rebase Created 3 years, 11 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-regexp.cc ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-string.cc
diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc
index 0e11bd71ded296cc4be0c142e0a02061aff5dfc9..daf48bd34800f197e52eb30ad8f2473959c8fa4e 100644
--- a/src/builtins/builtins-string.cc
+++ b/src/builtins/builtins-string.cc
@@ -1180,6 +1180,8 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
// Convert {receiver} and {search} to strings.
Callable tostring_callable = CodeFactory::ToString(isolate());
+ Callable indexof_callable = CodeFactory::StringIndexOf(isolate());
+
Node* const subject_string = CallStub(tostring_callable, context, receiver);
Node* const search_string = CallStub(tostring_callable, context, search);
@@ -1196,10 +1198,11 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
GotoIf(TaggedIsSmi(replace), &next);
GotoUnless(IsString(replace), &next);
- Node* const dollar_char = Int32Constant('$');
- Node* const index_of_dollar =
- StringIndexOfChar(context, replace, dollar_char, smi_zero);
- GotoUnless(SmiIsNegative(index_of_dollar), &next);
+ Node* const dollar_string = HeapConstant(
+ isolate()->factory()->LookupSingleCharacterStringFromCode('$'));
+ Node* const dollar_ix =
+ CallStub(indexof_callable, context, replace, dollar_string, smi_zero);
+ GotoUnless(SmiIsNegative(dollar_ix), &next);
// Searching by traversing a cons string tree and replace with cons of
// slices works only when the replaced string is a single character, being
@@ -1211,13 +1214,12 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
Bind(&next);
}
- // TODO(jgruber): Extend StringIndexOfChar to handle two-byte strings and
+ // TODO(jgruber): Extend StringIndexOf to handle two-byte strings and
// longer substrings - we can handle up to 8 chars (one-byte) / 4 chars
// (2-byte).
- Callable indexof_stub = CodeFactory::StringIndexOf(isolate());
- Node* const match_start_index =
- CallStub(indexof_stub, context, subject_string, search_string, smi_zero);
+ Node* const match_start_index = CallStub(
+ indexof_callable, context, subject_string, search_string, smi_zero);
CSA_ASSERT(this, TaggedIsSmi(match_start_index));
// Early exit if no match found.
« no previous file with comments | « src/builtins/builtins-regexp.cc ('k') | src/code-stub-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698