js/src/jit-test/tests/debug/optimized-out-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/optimized-out-01.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +// Tests that we can reflect optimized out values.
     1.5 +//
     1.6 +// Unfortunately these tests are brittle. They depend on opaque JIT heuristics
     1.7 +// kicking in.
     1.8 +
     1.9 +load(libdir + "jitopts.js");
    1.10 +
    1.11 +if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation))
    1.12 +  quit(0);
    1.13 +
    1.14 +withJitOptions(Opts_Ion2NoParallelCompilation, function () {
    1.15 +  var g = newGlobal();
    1.16 +  var dbg = new Debugger;
    1.17 +
    1.18 +  // Note that this *depends* on CCW scripted functions being opaque to Ion
    1.19 +  // optimization and not deoptimizing the frames below the call to toggle.
    1.20 +  g.toggle = function toggle(d) {
    1.21 +    if (d) {
    1.22 +      dbg.addDebuggee(g);
    1.23 +      var frame = dbg.getNewestFrame();
    1.24 +      assertEq(frame.implementation, "ion");
    1.25 +      // x is unused and should be elided.
    1.26 +      assertEq(frame.environment.getVariable("x").optimizedOut, true);
    1.27 +      assertEq(frame.arguments[1].optimizedOut, true);
    1.28 +    }
    1.29 +  };
    1.30 +
    1.31 +  g.eval("" + function f(d, x) { "use strict"; g(d, x); });
    1.32 +
    1.33 +  g.eval("" + function g(d, x) {
    1.34 +    "use strict";
    1.35 +    for (var i = 0; i < 200; i++);
    1.36 +    // Hack to prevent inlining.
    1.37 +    function inner() { i = 42; };
    1.38 +    toggle(d);
    1.39 +  });
    1.40 +
    1.41 +  g.eval("(" + function test() {
    1.42 +    for (i = 0; i < 5; i++)
    1.43 +      f(false, 42);
    1.44 +    f(true, 42);
    1.45 +  } + ")();");
    1.46 +});

mercurial