mirror of
https://github.com/tc39/test262.git
synced 2025-05-05 07:20:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
// This test ensures the TailCallInilnedCaller has the correct
|
|
// stack trace in the FTL inside a try block.
|
|
// This case arises when you have a situation like this:
|
|
// foo makes a call to bar, bar is inlined in foo. bar makes a call
|
|
// to baz and baz is inlined in bar. And then baz makes a tail-call to jaz,
|
|
// and jaz is inlined in baz. We want the callframe for jaz to appear to
|
|
// have caller be bar.
|
|
|
|
|
|
"use strict";
|
|
function value() {
|
|
return "value";
|
|
}
|
|
noInline(value);
|
|
|
|
function assert(b) {
|
|
if (!b)
|
|
throw new Error("bad value");
|
|
}
|
|
noInline(assert);
|
|
|
|
function validate(stack) {
|
|
let arr = stack.split("\n");
|
|
assert(arr[0].indexOf("jaz") !== -1);
|
|
assert(arr[1].indexOf("bar") !== -1);
|
|
assert(arr[2].indexOf("foo") !== -1);
|
|
}
|
|
|
|
function foo() {
|
|
let v = value();
|
|
try {
|
|
return bar() + 1;
|
|
} catch(e) {
|
|
assert(v === "value");
|
|
validate(e.stack);
|
|
}
|
|
}
|
|
noInline(foo);
|
|
|
|
function bar() {
|
|
return baz() + 1;
|
|
}
|
|
|
|
function baz() {
|
|
return jaz();
|
|
}
|
|
|
|
let flag = false;
|
|
function jaz() {
|
|
if (flag)
|
|
throw new Error("lol");
|
|
return 20;
|
|
}
|
|
noInline(jaz);
|
|
|
|
for (var i = 0; i < 50000; i++) {
|
|
foo();
|
|
}
|
|
flag = true;
|
|
foo();
|