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

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

Issue 2668703002: [stubs] Add RegExpReplace and RegExpSplit stubs (Closed)
Patch Set: BranchIfFastRegExp/IsFastRegExpMap Created 3 years, 10 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-factory.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 dddd32a8cd04a1c78ccf6a159e91df86d343f1e1..acb662bd718d3e1a85e483e509be21e31cdfd20a 100644
--- a/src/builtins/builtins-string.cc
+++ b/src/builtins/builtins-string.cc
@@ -1115,7 +1115,7 @@ void StringBuiltinsAssembler::MaybeCallFunctionAtSymbol(
}
// Take the fast path for RegExps.
- if (regexp_call != nullptr) {
+ {
Label stub_call(this), slow_lookup(this);
RegExpBuiltinsAssembler regexp_asm(state());
@@ -1160,10 +1160,18 @@ TF_BUILTIN(StringPrototypeReplace, StringBuiltinsAssembler) {
RequireObjectCoercible(context, receiver, "String.prototype.replace");
// Redirect to replacer method if {search[@@replace]} is not undefined.
- // TODO(jgruber): Call RegExp.p.replace stub for fast path.
MaybeCallFunctionAtSymbol(
- context, search, isolate()->factory()->replace_symbol(), nullptr,
+ context, search, isolate()->factory()->replace_symbol(),
+ [=]() {
+ Callable tostring_callable = CodeFactory::ToString(isolate());
+ Node* const subject_string =
+ CallStub(tostring_callable, context, receiver);
+
+ Callable replace_callable = CodeFactory::RegExpReplace(isolate());
+ return CallStub(replace_callable, context, search, subject_string,
+ replace);
+ },
[=](Node* fn) {
Callable call_callable = CodeFactory::Call(isolate());
return CallJS(call_callable, context, fn, search, receiver, replace);
@@ -1317,10 +1325,18 @@ TF_BUILTIN(StringPrototypeSplit, StringBuiltinsAssembler) {
RequireObjectCoercible(context, receiver, "String.prototype.split");
// Redirect to splitter method if {separator[@@split]} is not undefined.
- // TODO(jgruber): Call RegExp.p.split stub for fast path.
MaybeCallFunctionAtSymbol(
- context, separator, isolate()->factory()->split_symbol(), nullptr,
+ context, separator, isolate()->factory()->split_symbol(),
+ [=]() {
+ Callable tostring_callable = CodeFactory::ToString(isolate());
+ Node* const subject_string =
+ CallStub(tostring_callable, context, receiver);
+
+ Callable split_callable = CodeFactory::RegExpSplit(isolate());
+ return CallStub(split_callable, context, separator, subject_string,
+ limit);
+ },
[=](Node* fn) {
Callable call_callable = CodeFactory::Call(isolate());
return CallJS(call_callable, context, fn, separator, receiver, limit);
« no previous file with comments | « src/builtins/builtins-regexp.cc ('k') | src/code-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698