Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // |jit-test| error:AllDone |
michael@0 | 2 | // When we enter debug mode in a compartment, we must throw away all |
michael@0 | 3 | // analyses in that compartment (debug mode affects the results of |
michael@0 | 4 | // analysis, so they become out of date). This is true even when we would |
michael@0 | 5 | // otherwise be retaining jit code and its related data structures for |
michael@0 | 6 | // animation timing. |
michael@0 | 7 | |
michael@0 | 8 | if (typeof gcPreserveCode != "function") |
michael@0 | 9 | throw('AllDone'); |
michael@0 | 10 | |
michael@0 | 11 | var g = newGlobal(); |
michael@0 | 12 | var dbg = new Debugger; |
michael@0 | 13 | |
michael@0 | 14 | g.eval("" + |
michael@0 | 15 | function fib(n) { |
michael@0 | 16 | var a = 0, b = 1; |
michael@0 | 17 | while (n-- > 0) |
michael@0 | 18 | b = b+a, a = b-a; |
michael@0 | 19 | return b; |
michael@0 | 20 | }); |
michael@0 | 21 | |
michael@0 | 22 | g.fib(20); // Cause g.fib to be jitted. This creates an analysis with |
michael@0 | 23 | // debug mode off. |
michael@0 | 24 | |
michael@0 | 25 | gcPreserveCode(); // Tell the gc to preserve JIT code and analyses by |
michael@0 | 26 | // default. A recent call to js::NotifyAnimationActivity |
michael@0 | 27 | // could have a similar effect in real life. |
michael@0 | 28 | |
michael@0 | 29 | dbg.addDebuggee(g); // Put g in debug mode. This triggers a GC which must |
michael@0 | 30 | // clear all analyses. In the original buggy code, we also |
michael@0 | 31 | // release all of g's scripts' JIT code, leading to a |
michael@0 | 32 | // recompilation the next time it was called. |
michael@0 | 33 | |
michael@0 | 34 | g.fib(20); // Run g.fib again, causing it to be re-jitted. If the |
michael@0 | 35 | // original analysis is still present, JM will assert, |
michael@0 | 36 | // because it is not in debug mode. |
michael@0 | 37 | |
michael@0 | 38 | throw('AllDone'); |