| Index: src/runtime/runtime-regexp.cc
|
| diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
|
| index ac1369ddcc4c52a43a10b5447c3256429192fda2..0c08025bce543d678c72d3708564cb36a5a2de65 100644
|
| --- a/src/runtime/runtime-regexp.cc
|
| +++ b/src/runtime/runtime-regexp.cc
|
| @@ -1461,6 +1461,30 @@ MaybeHandle<String> RegExpReplace(Isolate* isolate, Handle<JSRegExp> regexp,
|
|
|
| } // namespace
|
|
|
| +RUNTIME_FUNCTION(Runtime_StringReplaceGlobalRegExpWithFunction) {
|
| + HandleScope scope(isolate);
|
| + DCHECK(args.length() == 3);
|
| +
|
| + CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, replace, 2);
|
| +
|
| + RETURN_RESULT_OR_FAILURE(isolate, StringReplaceGlobalRegExpWithFunction(
|
| + isolate, subject, regexp, replace));
|
| +}
|
| +
|
| +RUNTIME_FUNCTION(Runtime_StringReplaceNonGlobalRegExpWithFunction) {
|
| + HandleScope scope(isolate);
|
| + DCHECK(args.length() == 3);
|
| +
|
| + CONVERT_ARG_HANDLE_CHECKED(String, subject, 0);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, replace, 2);
|
| +
|
| + RETURN_RESULT_OR_FAILURE(isolate, StringReplaceNonGlobalRegExpWithFunction(
|
| + isolate, subject, regexp, replace));
|
| +}
|
| +
|
| // Slow path for:
|
| // ES#sec-regexp.prototype-@@replace
|
| // RegExp.prototype [ @@replace ] ( string, replaceValue )
|
| @@ -1503,6 +1527,11 @@ RUNTIME_FUNCTION(Runtime_RegExpReplace) {
|
| RegExpUtils::SetLastIndex(isolate, recv, 0));
|
| }
|
|
|
| + // TODO(jgruber): Here and at all other fast path checks, rely on map checks
|
| + // instead.
|
| + // TODO(jgruber): We could speed up the fast path by checking flags
|
| + // afterwards, but that would violate the spec (which states that exec is
|
| + // accessed after global and unicode).
|
| // TODO(adamk): this fast path is wrong as we doesn't ensure that 'exec'
|
| // is actually a data property on RegExp.prototype.
|
| Handle<Object> exec = factory->undefined_value();
|
|
|