js/src/jit-test/tests/debug/Environment-getVariable-13.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/Environment-getVariable-13.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     1.4 +// Tests that we can use debug scopes with Ion frames.
     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 +      // g is heavyweight but its call object is optimized out, because its
    1.26 +      // arguments and locals are unaliased.
    1.27 +      //
    1.28 +      // Calling frame.environment here should make a fake debug scope that
    1.29 +      // gets things directly from the frame. Calling frame.arguments doesn't
    1.30 +      // go through the scope object and reads directly off the frame. Assert
    1.31 +      // that the two are equal.
    1.32 +      assertEq(frame.environment.getVariable("x"), frame.arguments[1]);
    1.33 +    }
    1.34 +  };
    1.35 +
    1.36 +  g.eval("" + function f(d, x) { g(d, x); });
    1.37 +  g.eval("" + function g(d, x) {
    1.38 +    for (var i = 0; i < 200; i++);
    1.39 +    function inner() { i = 42; };
    1.40 +    toggle(d);
    1.41 +    // Use x so it doesn't get optimized out.
    1.42 +    x++;
    1.43 +  });
    1.44 +
    1.45 +  g.eval("(" + function test() {
    1.46 +    for (i = 0; i < 5; i++)
    1.47 +      f(false, 42);
    1.48 +    f(true, 42);
    1.49 +  } + ")();");
    1.50 +});

mercurial