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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 // |jit-test| error:AllDone
     2 // When we leave debug mode in a compartment, we must throw away all
     3 // analyses in that compartment (debug mode affects the results of
     4 // analysis, so they become out of date). We cannot skip this step when
     5 // there are debuggee frames on the stack.
     7 var g = newGlobal();
     8 var dbg = new Debugger();
     9 var gw = dbg.addDebuggee(g);
    11 g.eval("" +
    12        function fib(n) {
    13          var a = 0, b = 1;
    14          while (n-- > 0)
    15            b = b+a, a = b-a;
    16          return b;
    17        });
    20 // Cause g.fib to be jitted. This creates an analysis with debug mode on.
    21 g.fib(20);
    23 // Setting a breakpoint in g.f causes us to throw away the jit code, but
    24 // not the analysis.
    25 gw.makeDebuggeeValue(g.fib).script.setBreakpoint(0, { hit: function (f) { } });
    27 // Take g out of debug mode, with debuggee code on the stack. In older
    28 // code, this would not trigger a cleansing GC, so the script will
    29 // retain its analysis.
    30 dbg.onDebuggerStatement = function (f) {
    31   dbg.removeDebuggee(g);
    32 };
    33 g.eval('debugger');
    35 // Run g.fib again, causing it to be re-jitted. If the original analysis is
    36 // still present, JM will assert, because it is not in debug mode.
    37 g.fib(20);
    39 throw('AllDone');

mercurial