]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/cloned-arguments-should-visit-callee-during-gc.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / cloned-arguments-should-visit-callee-during-gc.js
CommitLineData
ed1e77d3
A
1// Test that the ClonedArguments created by the Function.arguments will properly
2// keep its callee alive. This test should not crash and should not print any error
3// messages.
4
5var cachedArguments = [];
6var numberOfEntries = 1000;
7
8function makeTransientFunction(i) {
9 function transientFunc() {
10 cachedArguments[i] = transientFunc.arguments;
11 }
12 return transientFunc;
13}
14
15for (i = 0; i < numberOfEntries; i++) {
16 var transientFunc = makeTransientFunction(i);
17 transientFunc();
18 // At this point, the only reference to the transient function is from
19 // cachedArguments[i].callee.
20}
21
22gc();
23
24// Allocate a bunch of memory to stomp over the transient functions that may have been
25// erroneously collected. webkit.org/b/145709
26for (i = 0; i < numberOfEntries; i++) {
27 new Object();
28}
29
30for (i = 0; i < numberOfEntries; i++) {
31 var callee = cachedArguments[i].callee;
32 if (typeof callee != "function")
33 print("ERROR: callee is " + callee);
34}