test262/implementation-contributed/javascriptcore/stress/load-varargs-elimination-bounds-check-barely.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

36 lines
770 B
JavaScript

function foo() {
var result = 0;
for (var i = 0; i < arguments.length; ++i)
result += arguments[i];
return result;
}
function bar() {
return foo.apply(this, arguments);
}
function baz(p) {
if (p)
return bar(1, 42);
return 0;
}
noInline(baz);
// Execute baz() once with p set, so that the call has a valid prediction.
baz(true);
// Warm up profiling in bar and foo. Convince this profiling that bar()'s varargs call will tend to
// pass a small number of arguments;
for (var i = 0; i < 1000; ++i)
bar(1);
// Now compile baz(), but don't run the bad code yet.
for (var i = 0; i < 10000; ++i)
baz(false);
// Finally, trigger the bug.
var result = baz(true);
if (result != 43)
throw "Error: bad result: " + result;