test262/implementation-contributed/javascriptcore/stress/elide-new-object-dag-then-exit.js
test262-automation e9a5a7f918 [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) (#1620)
* [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)
2018-07-03 15:59:58 -04:00

44 lines
1.0 KiB
JavaScript

function sumOfArithSeries(limit) {
return limit * (limit + 1) / 2;
}
var n = 10000000;
function bar() { }
function verify(q, i) {
if (q.f == q.g)
throw "Error: q.f == q.g";
if (q.f.f != q.g.f)
throw "Error: q.f.f != q.g.f";
if (q.f.f.f != i)
throw "Error: q.f.f.f != i";
}
function foo() {
var result = 0;
for (var i = 0; i < n; ++i) {
var leaf = {f:i};
var o = {f:leaf};
var p = {f:leaf};
var q = {f:o, g:p};
result += q.f.f.f;
if (i >= n - 100) {
// We want the materialization to happen in the exit. So, before calling the thing that
// causes the materialization, we call bar(). We've never profiled this call at the time
// of FTL compilation, so this should be an exit.
bar();
verify(q, i);
}
}
return result;
}
noInline(foo);
noInline(verify);
noInline(bar);
var result = foo();
if (result != sumOfArithSeries(n - 1))
throw "Error: bad result: " + result;