blob: 3125a5e377e3a1e1c83825662414cb110ce097aa [file] [log] [blame]
function sumOfArithSeries(limit) {
return limit * (limit + 1) / 2;
}
var n = 10000000;
function bar() { }
function foo(b) {
var result = 0;
for (var i = 0; i < n; ++i) {
var o = {f: i};
var p = {f: i + 1};
if (b) {
bar(o, p);
return;
}
result += o.f + p.f;
}
return result;
}
noInline(bar);
noInline(foo);
var result = foo(false);
if (result != sumOfArithSeries(n - 1) + sumOfArithSeries(n))
throw "Error: bad result: " + result;