Commit 9fbfd6ea authored by jgruber's avatar jgruber Committed by Commit bot

[regexp] Don't adapt arguments for @@replace and @@split

Mechanical change to remove argument adaption from RegExp.p.split,
RegExp.p.replace when the actual arguments counts does not match
the formal parameter count (should be a tad faster this way).

BUG=v8:6369

Review-Url: https://codereview.chromium.org/2865313002
Cr-Commit-Position: refs/heads/master@{#45219}
parent 7cce5358
......@@ -2286,7 +2286,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
Handle<JSFunction> fun = SimpleCreateFunction(
isolate, factory->InternalizeUtf8String("[Symbol.replace]"),
Builtins::kRegExpPrototypeReplace, 2, true);
Builtins::kRegExpPrototypeReplace, 2, false);
InstallFunction(prototype, fun, factory->replace_symbol(), DONT_ENUM);
}
......@@ -2300,7 +2300,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
{
Handle<JSFunction> fun = SimpleCreateFunction(
isolate, factory->InternalizeUtf8String("[Symbol.split]"),
Builtins::kRegExpPrototypeSplit, 2, true);
Builtins::kRegExpPrototypeSplit, 2, false);
InstallFunction(prototype, fun, factory->split_symbol(), DONT_ENUM);
}
......
......@@ -808,11 +808,11 @@ namespace internal {
\
TFS(RegExpReplace, kRegExp, kString, kReplaceValue) \
/* ES #sec-regexp.prototype-@@replace */ \
TFJ(RegExpPrototypeReplace, 2, kString, kReplaceValue) \
TFJ(RegExpPrototypeReplace, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
\
TFS(RegExpSplit, kRegExp, kString, kLimit) \
/* ES #sec-regexp.prototype-@@split */ \
TFJ(RegExpPrototypeSplit, 2, kString, kLimit) \
TFJ(RegExpPrototypeSplit, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
\
/* SharedArrayBuffer */ \
CPP(SharedArrayBufferPrototypeGetByteLength) \
......
......@@ -2437,10 +2437,19 @@ TF_BUILTIN(RegExpSplit, RegExpBuiltinsAssembler) {
// ES#sec-regexp.prototype-@@split
// RegExp.prototype [ @@split ] ( string, limit )
TF_BUILTIN(RegExpPrototypeSplit, RegExpBuiltinsAssembler) {
Node* const maybe_receiver = Parameter(Descriptor::kReceiver);
Node* const maybe_string = Parameter(Descriptor::kString);
Node* const maybe_limit = Parameter(Descriptor::kLimit);
Node* const context = Parameter(Descriptor::kContext);
const int kStringArg = 0;
const int kLimitArg = 1;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* const maybe_receiver = args.GetReceiver();
Node* const maybe_string =
args.GetOptionalArgumentValue(kStringArg, UndefinedConstant());
Node* const maybe_limit =
args.GetOptionalArgumentValue(kLimitArg, UndefinedConstant());
Node* const context = Parameter(BuiltinDescriptor::kContext);
// Ensure {maybe_receiver} is a JSReceiver.
ThrowIfNotJSReceiver(context, maybe_receiver,
......@@ -2455,12 +2464,12 @@ TF_BUILTIN(RegExpPrototypeSplit, RegExpBuiltinsAssembler) {
BranchIfFastRegExp(context, receiver, &stub, &runtime);
BIND(&stub);
Return(CallBuiltin(Builtins::kRegExpSplit, context, receiver, string,
maybe_limit));
args.PopAndReturn(CallBuiltin(Builtins::kRegExpSplit, context, receiver,
string, maybe_limit));
BIND(&runtime);
Return(CallRuntime(Runtime::kRegExpSplit, context, receiver, string,
maybe_limit));
args.PopAndReturn(CallRuntime(Runtime::kRegExpSplit, context, receiver,
string, maybe_limit));
}
Node* RegExpBuiltinsAssembler::ReplaceGlobalCallableFastPath(
......@@ -2850,10 +2859,19 @@ TF_BUILTIN(RegExpReplace, RegExpBuiltinsAssembler) {
// ES#sec-regexp.prototype-@@replace
// RegExp.prototype [ @@replace ] ( string, replaceValue )
TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) {
Node* const maybe_receiver = Parameter(Descriptor::kReceiver);
Node* const maybe_string = Parameter(Descriptor::kString);
Node* const replace_value = Parameter(Descriptor::kReplaceValue);
Node* const context = Parameter(Descriptor::kContext);
const int kStringArg = 0;
const int kReplaceValueArg = 1;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* const maybe_receiver = args.GetReceiver();
Node* const maybe_string =
args.GetOptionalArgumentValue(kStringArg, UndefinedConstant());
Node* const replace_value =
args.GetOptionalArgumentValue(kReplaceValueArg, UndefinedConstant());
Node* const context = Parameter(BuiltinDescriptor::kContext);
// RegExpPrototypeReplace is a bit of a beast - a summary of dispatch logic:
//
......@@ -2887,12 +2905,12 @@ TF_BUILTIN(RegExpPrototypeReplace, RegExpBuiltinsAssembler) {
BranchIfFastRegExp(context, receiver, &stub, &runtime);
BIND(&stub);
Return(CallBuiltin(Builtins::kRegExpReplace, context, receiver, string,
replace_value));
args.PopAndReturn(CallBuiltin(Builtins::kRegExpReplace, context, receiver,
string, replace_value));
BIND(&runtime);
Return(CallRuntime(Runtime::kRegExpReplace, context, receiver, string,
replace_value));
args.PopAndReturn(CallRuntime(Runtime::kRegExpReplace, context, receiver,
string, replace_value));
}
// Simple string matching functionality for internal use which does not modify
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment