[turbofan] Don't try to optimize tail calls to .apply.

BUG=chromium:685634
R=ishell@chromium.org

Review-Url: https://codereview.chromium.org/2658853002
Cr-Commit-Position: refs/heads/master@{#42713}
This commit is contained in:
bmeurer 2017-01-26 12:52:21 -08:00 committed by Commit bot
parent 9d9711a8eb
commit 7be3b4c90f
2 changed files with 18 additions and 0 deletions

View File

@ -79,6 +79,10 @@ Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
Node* target = NodeProperties::GetValueInput(node, 0);
CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
// Tail calls to Function.prototype.apply are not properly supported
// down the pipeline, so we disable this optimization completely for
// tail calls (for now).
if (p.tail_call_mode() == TailCallMode::kAllow) return NoChange();
Handle<JSFunction> apply =
Handle<JSFunction>::cast(HeapObjectMatcher(target).Value());
size_t arity = p.arity();

View File

@ -0,0 +1,14 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --harmony-tailcalls
"use strict";
function foo(f) { return f.apply(this, arguments); }
function bar() {}
foo(bar);
%OptimizeFunctionOnNextCall(foo);
foo(bar);