Commit 7cce5358 authored by jgruber's avatar jgruber Committed by Commit bot

[array] Don't adapt arguments for ArrayIndexOf and ArrayIncludes

Mechanical change to remove argument adaption from Array.p.indexOf and
Array.p.includes when the actual arguments counts does not match the formal
parameter count.

BUG=v8:6369

Review-Url: https://codereview.chromium.org/2873653002
Cr-Commit-Position: refs/heads/master@{#45218}
parent dccfe5db
......@@ -1355,10 +1355,19 @@ TF_BUILTIN(ArrayIsArray, CodeStubAssembler) {
}
TF_BUILTIN(ArrayIncludes, CodeStubAssembler) {
Node* const array = Parameter(Descriptor::kReceiver);
Node* const search_element = Parameter(Descriptor::kSearchElement);
Node* const start_from = Parameter(Descriptor::kFromIndex);
Node* const context = Parameter(Descriptor::kContext);
const int kSearchElementArg = 0;
const int kFromIndexArg = 1;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* array = args.GetReceiver();
Node* search_element =
args.GetOptionalArgumentValue(kSearchElementArg, UndefinedConstant());
Node* start_from =
args.GetOptionalArgumentValue(kFromIndexArg, UndefinedConstant());
Node* const context = Parameter(BuiltinDescriptor::kContext);
VARIABLE(index_var, MachineType::PointerRepresentation());
......@@ -1633,21 +1642,30 @@ TF_BUILTIN(ArrayIncludes, CodeStubAssembler) {
}
BIND(&return_true);
Return(TrueConstant());
args.PopAndReturn(TrueConstant());
BIND(&return_false);
Return(FalseConstant());
args.PopAndReturn(FalseConstant());
BIND(&call_runtime);
Return(CallRuntime(Runtime::kArrayIncludes_Slow, context, array,
search_element, start_from));
args.PopAndReturn(CallRuntime(Runtime::kArrayIncludes_Slow, context, array,
search_element, start_from));
}
TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) {
Node* array = Parameter(Descriptor::kReceiver);
Node* search_element = Parameter(Descriptor::kSearchElement);
Node* start_from = Parameter(Descriptor::kFromIndex);
Node* context = Parameter(Descriptor::kContext);
const int kSearchElementArg = 0;
const int kFromIndexArg = 1;
Node* argc =
ChangeInt32ToIntPtr(Parameter(BuiltinDescriptor::kArgumentsCount));
CodeStubArguments args(this, argc);
Node* array = args.GetReceiver();
Node* search_element =
args.GetOptionalArgumentValue(kSearchElementArg, UndefinedConstant());
Node* start_from =
args.GetOptionalArgumentValue(kFromIndexArg, UndefinedConstant());
Node* context = Parameter(BuiltinDescriptor::kContext);
Node* intptr_zero = IntPtrConstant(0);
Node* intptr_one = IntPtrConstant(1);
......@@ -1898,14 +1916,14 @@ TF_BUILTIN(ArrayIndexOf, CodeStubAssembler) {
}
BIND(&return_found);
Return(SmiTag(index_var.value()));
args.PopAndReturn(SmiTag(index_var.value()));
BIND(&return_not_found);
Return(NumberConstant(-1));
args.PopAndReturn(NumberConstant(-1));
BIND(&call_runtime);
Return(CallRuntime(Runtime::kArrayIndexOf, context, array, search_element,
start_from));
args.PopAndReturn(CallRuntime(Runtime::kArrayIndexOf, context, array,
search_element, start_from));
}
class ArrayPrototypeIterationAssembler : public CodeStubAssembler {
......
......@@ -252,9 +252,9 @@ namespace internal {
/* ES6 #sec-array.isarray */ \
TFJ(ArrayIsArray, 1, kArg) \
/* ES7 #sec-array.prototype.includes */ \
TFJ(ArrayIncludes, 2, kSearchElement, kFromIndex) \
TFJ(ArrayIncludes, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 #sec-array.prototype.indexof */ \
TFJ(ArrayIndexOf, 2, kSearchElement, kFromIndex) \
TFJ(ArrayIndexOf, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
/* ES6 #sec-array.prototype.pop */ \
CPP(ArrayPop) \
TFJ(FastArrayPop, SharedFunctionInfo::kDontAdaptArgumentsSentinel) \
......
......@@ -58,8 +58,8 @@ RUNTIME_FUNCTION(Runtime_SpecialArrayFunctions) {
InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes, 2);
InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf, 2);
InstallBuiltin(isolate, holder, "includes", Builtins::kArrayIncludes);
InstallBuiltin(isolate, holder, "indexOf", Builtins::kArrayIndexOf);
InstallBuiltin(isolate, holder, "keys", Builtins::kArrayPrototypeKeys, 0,
kArrayKeys);
InstallBuiltin(isolate, holder, "values", Builtins::kArrayPrototypeValues, 0,
......
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