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

Unified Diff: src/compiler/js-call-reducer.cc

Issue 2684963002: [turbofan] Avoid going through ArgumentsAdaptorTrampoline for CSA/C++ builtins. (Closed)
Patch Set: Exclude JavaScript builtins. Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-call-reducer.cc
diff --git a/src/compiler/js-call-reducer.cc b/src/compiler/js-call-reducer.cc
index 21148b3d20d6351d82cbbc3913745762129b52b1..b2b9bf717c920ee401ec7eaca89267922e1daa62 100644
--- a/src/compiler/js-call-reducer.cc
+++ b/src/compiler/js-call-reducer.cc
@@ -520,11 +520,44 @@ 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 (shared->code()->builtin_index()) {
+ switch (builtin_index) {
case Builtins::kFunctionPrototypeApply:
return ReduceFunctionPrototypeApply(node);
case Builtins::kFunctionPrototypeCall:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698