michael@0: // |jit-test| error:AllDone michael@0: // When we enter debug mode in a compartment, we must throw away all michael@0: // analyses in that compartment (debug mode affects the results of michael@0: // analysis, so they become out of date). This is true even when we would michael@0: // otherwise be retaining jit code and its related data structures for michael@0: // animation timing. michael@0: michael@0: if (typeof gcPreserveCode != "function") michael@0: throw('AllDone'); michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger; michael@0: michael@0: g.eval("" + michael@0: function fib(n) { michael@0: var a = 0, b = 1; michael@0: while (n-- > 0) michael@0: b = b+a, a = b-a; michael@0: return b; michael@0: }); michael@0: michael@0: g.fib(20); // Cause g.fib to be jitted. This creates an analysis with michael@0: // debug mode off. michael@0: michael@0: gcPreserveCode(); // Tell the gc to preserve JIT code and analyses by michael@0: // default. A recent call to js::NotifyAnimationActivity michael@0: // could have a similar effect in real life. michael@0: michael@0: dbg.addDebuggee(g); // Put g in debug mode. This triggers a GC which must michael@0: // clear all analyses. In the original buggy code, we also michael@0: // release all of g's scripts' JIT code, leading to a michael@0: // recompilation the next time it was called. michael@0: michael@0: g.fib(20); // Run g.fib again, causing it to be re-jitted. If the michael@0: // original analysis is still present, JM will assert, michael@0: // because it is not in debug mode. michael@0: michael@0: throw('AllDone');