Commit d98dfd8b authored by bmeurer's avatar bmeurer Committed by Commit bot

Revert "[turbofan] Avoid going through ArgumentsAdaptorTrampoline for CSA/C++ builtins."

This reverts commit 9df5674b because it
is not compatible with the way that Array.prototype.reduceRight and
Array.prototype.reduce deal with optional parameters at this point (i.e.
parameters where the behavior is different depending on whether the
parameter was skipped or undefined was passed).

In general, it might be better to not adapt arguments for builtins with
optional paramters, that are likely skipped, for example as in
Object.create or Array.prototype.reduce. Since that will require
arguments adaptor frames for normal calls, especially from baseline
code. Instead it might make sense to use the variadic arguments support
in the CodeStubAssembler instead to avoid the arguments adaptor in all
cases (not only when called from TurboFan optimized code).

BUG=v8:5267,chromium:709782,chromium:707992,chromium:708282,chromium:708599,chromium:709173,chromium:709747,chromium:707065,chromium:710417
TBR=danno@chromium.org

Review-Url: https://codereview.chromium.org/2817653002
Cr-Commit-Position: refs/heads/master@{#44593}
parent 7829af32
......@@ -544,44 +544,11 @@ Reduction JSCallReducer::ReduceJSCall(Node* node) {
return Changed(node);
}
// For CSA/C++ builtin {target}s, we can ensure that the number
// of parameters we pass to the {target} matches exactly the
// number of formal parameters expected by the builtin, and thus
// avoid creating an ArgumentsAdaptorFrame. This is safe because
// all CSA/C++ builtins that care about variable arguments are
// declared with the kDontAdaptArgumentsSentinel marker.
int builtin_index = shared->code()->builtin_index();
if (builtin_index != -1 && shared->native() && !shared->IsInterpreted()) {
// Check if we have an arguments mismatch for {target}.
int arity = static_cast<int>(p.arity() - 2);
int num_parameters = shared->internal_formal_parameter_count();
if (num_parameters != arity &&
num_parameters != SharedFunctionInfo::kDontAdaptArgumentsSentinel) {
// Fill up missing parameters with undefined.
while (arity < num_parameters) {
node->InsertInput(graph()->zone(), arity + 2,
jsgraph()->UndefinedConstant());
arity++;
}
// Remove additional parameters.
while (arity > num_parameters) {
node->RemoveInput(arity + 1);
arity--;
}
NodeProperties::ChangeOp(
node, javascript()->Call(arity + 2, p.frequency(), p.feedback(),
p.convert_mode(), p.tail_call_mode()));
// Try to further reduce the JSCall {node}.
Reduction const reduction = ReduceJSCall(node);
return reduction.Changed() ? reduction : Changed(node);
}
}
// Don't inline cross native context.
if (function->native_context() != *native_context()) return NoChange();
// Check for known builtin functions.
switch (builtin_index) {
switch (shared->code()->builtin_index()) {
case Builtins::kBooleanConstructor:
return ReduceBooleanConstructor(node);
case Builtins::kFunctionPrototypeApply:
......
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