test262/implementation-contributed/javascriptcore/stress/cloned-arguments-should-visit-callee-during-gc.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

35 lines
984 B
JavaScript

// Test that the ClonedArguments created by the Function.arguments will properly
// keep its callee alive. This test should not crash and should not print any error
// messages.
var cachedArguments = [];
var numberOfEntries = 1000;
function makeTransientFunction(i) {
function transientFunc() {
cachedArguments[i] = transientFunc.arguments;
}
return transientFunc;
}
for (i = 0; i < numberOfEntries; i++) {
var transientFunc = makeTransientFunction(i);
transientFunc();
// At this point, the only reference to the transient function is from
// cachedArguments[i].callee.
}
gc();
// Allocate a bunch of memory to stomp over the transient functions that may have been
// erroneously collected. webkit.org/b/145709
for (i = 0; i < numberOfEntries; i++) {
new Object();
}
for (i = 0; i < numberOfEntries; i++) {
var callee = cachedArguments[i].callee;
if (typeof callee != "function")
print("ERROR: callee is " + callee);
}