d64b41ded6
Reason for revert: [Sheriff] Leads to mac gc stress crashes: https://build.chromium.org/p/client.v8/builders/V8%20Mac%20GC%20Stress/builds/4975 Original issue's description: > [crankshaft] Fixing ES6 tail call elimination. > > In case when F inlined normal call to G which tail calls H we should not write translation for G for the tail call site. > Otherwise we will see G in a stack trace inside H. > > This CL also enables all existing tests related to ES6 tail call elimination. > > TBR=bmeurer@chromium.org > BUG=v8:4698 > LOG=N > > Committed: https://crrev.com/689980f7d4dfd4c29492f616d7b616b86ec9af91 > Cr-Commit-Position: refs/heads/master@{#34830} TBR=mstarzinger@chromium.org,ishell@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:4698 Review URL: https://codereview.chromium.org/1814433002 Cr-Commit-Position: refs/heads/master@{#34835}
146 lines
2.7 KiB
JavaScript
146 lines
2.7 KiB
JavaScript
// Copyright 2016 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 --stack-size=100
|
|
// TODO(v8:4698), TODO(ishell): support these cases.
|
|
// Flags: --nostress-opt
|
|
|
|
//
|
|
// Tail calls work only in strict mode.
|
|
//
|
|
(function() {
|
|
function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return f(n - 1);
|
|
}
|
|
assertThrows(()=>{ f(1e5) });
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertThrows(()=>{ f(1e5) });
|
|
})();
|
|
|
|
|
|
//
|
|
// Tail call normal functions.
|
|
//
|
|
(function() {
|
|
"use strict";
|
|
function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return f(n - 1);
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
})();
|
|
|
|
|
|
(function() {
|
|
"use strict";
|
|
function f(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return f(n - 1, 42); // Call with arguments adaptor.
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
})();
|
|
|
|
|
|
(function() {
|
|
"use strict";
|
|
function f(n){
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return g(n - 1);
|
|
}
|
|
function g(n){
|
|
if (n <= 0) {
|
|
return "bar";
|
|
}
|
|
return f(n - 1);
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
})();
|
|
|
|
|
|
(function() {
|
|
"use strict";
|
|
function f(n){
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return g(n - 1, 42); // Call with arguments adaptor.
|
|
}
|
|
function g(n){
|
|
if (n <= 0) {
|
|
return "bar";
|
|
}
|
|
return f(n - 1, 42); // Call with arguments adaptor.
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
})();
|
|
|
|
|
|
//
|
|
// Tail call bound functions.
|
|
//
|
|
(function() {
|
|
"use strict";
|
|
function f0(n) {
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return f_bound(n - 1);
|
|
}
|
|
var f_bound = f0.bind({});
|
|
function f(n) {
|
|
return f_bound(n);
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
})();
|
|
|
|
|
|
(function() {
|
|
"use strict";
|
|
function f0(n){
|
|
if (n <= 0) {
|
|
return "foo";
|
|
}
|
|
return g_bound(n - 1);
|
|
}
|
|
function g0(n){
|
|
if (n <= 0) {
|
|
return "bar";
|
|
}
|
|
return f_bound(n - 1);
|
|
}
|
|
var f_bound = f0.bind({});
|
|
var g_bound = g0.bind({});
|
|
function f(n) {
|
|
return f_bound(n);
|
|
}
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("foo", f(1e5));
|
|
assertEquals("bar", f(1e5 + 1));
|
|
})();
|