js/src/jit-test/tests/debug/optimized-out-01.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Tests that we can reflect optimized out values.
     2 //
     3 // Unfortunately these tests are brittle. They depend on opaque JIT heuristics
     4 // kicking in.
     6 load(libdir + "jitopts.js");
     8 if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation))
     9   quit(0);
    11 withJitOptions(Opts_Ion2NoParallelCompilation, function () {
    12   var g = newGlobal();
    13   var dbg = new Debugger;
    15   // Note that this *depends* on CCW scripted functions being opaque to Ion
    16   // optimization and not deoptimizing the frames below the call to toggle.
    17   g.toggle = function toggle(d) {
    18     if (d) {
    19       dbg.addDebuggee(g);
    20       var frame = dbg.getNewestFrame();
    21       assertEq(frame.implementation, "ion");
    22       // x is unused and should be elided.
    23       assertEq(frame.environment.getVariable("x").optimizedOut, true);
    24       assertEq(frame.arguments[1].optimizedOut, true);
    25     }
    26   };
    28   g.eval("" + function f(d, x) { "use strict"; g(d, x); });
    30   g.eval("" + function g(d, x) {
    31     "use strict";
    32     for (var i = 0; i < 200; i++);
    33     // Hack to prevent inlining.
    34     function inner() { i = 42; };
    35     toggle(d);
    36   });
    38   g.eval("(" + function test() {
    39     for (i = 0; i < 5; i++)
    40       f(false, 42);
    41     f(true, 42);
    42   } + ")();");
    43 });

mercurial