2 // Create a reference loop function->script->traceFragment->object->function
3 // that GC must be able to break. To embedd object into the fragment the
4 // code use prototype chain of depth 2 which caches obj.__proto__.__proto__
7 // To make sure that we have no references to the function f after this
8 // function returns due via the conservative scan of the native stack we
9 // loop here multiple times overwriting the stack and registers with new garabge.
10 for (var j = 0; j != 8; ++j) {
11 var f = Function("a", "var s = 0; for (var i = 0; i != 100; ++i) s += a.b; return s;");
12 var c = {b: 1, f: f, leakDetection: makeFinalizeObserver()};
13 f({ __proto__: { __proto__: c}});
21 if (typeof finalizeCount != "function")
24 var base = finalizeCount();
28 var n = finalizeCount();
29 assertEq(base + 4 < finalizeCount(), true, "Some finalizations must happen");