js/src/jit-test/tests/debug/clear-old-analyses-01.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/clear-old-analyses-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     1.4 +// |jit-test| error:AllDone
     1.5 +// When we enter debug mode in a compartment, we must throw away all
     1.6 +// analyses in that compartment (debug mode affects the results of
     1.7 +// analysis, so they become out of date). This is true even when we would
     1.8 +// otherwise be retaining jit code and its related data structures for
     1.9 +// animation timing.
    1.10 +
    1.11 +if (typeof gcPreserveCode != "function")
    1.12 +  throw('AllDone');
    1.13 +
    1.14 +var g = newGlobal();
    1.15 +var dbg = new Debugger;
    1.16 +
    1.17 +g.eval("" +
    1.18 +       function fib(n) {
    1.19 +         var a = 0, b = 1;
    1.20 +         while (n-- > 0)
    1.21 +           b = b+a, a = b-a;
    1.22 +         return b;
    1.23 +       });
    1.24 +
    1.25 +g.fib(20);                      // Cause g.fib to be jitted. This creates an analysis with
    1.26 +                                // debug mode off.
    1.27 +
    1.28 +gcPreserveCode();               // Tell the gc to preserve JIT code and analyses by
    1.29 +                                // default. A recent call to js::NotifyAnimationActivity
    1.30 +                                // could have a similar effect in real life.
    1.31 +
    1.32 +dbg.addDebuggee(g);             // Put g in debug mode. This triggers a GC which must
    1.33 +                                // clear all analyses. In the original buggy code, we also
    1.34 +                                // release all of g's scripts' JIT code, leading to a
    1.35 +                                // recompilation the next time it was called.
    1.36 +
    1.37 +g.fib(20);                      // Run g.fib again, causing it to be re-jitted. If the
    1.38 +                                // original analysis is still present, JM will assert,
    1.39 +                                // because it is not in debug mode.
    1.40 +
    1.41 +throw('AllDone');

mercurial