js/src/jit-test/tests/debug/Environment-getVariable-13.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

michael@0 1 // Tests that we can use debug scopes with Ion frames.
michael@0 2 //
michael@0 3 // Unfortunately these tests are brittle. They depend on opaque JIT heuristics
michael@0 4 // kicking in.
michael@0 5
michael@0 6 load(libdir + "jitopts.js");
michael@0 7
michael@0 8 if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation))
michael@0 9 quit(0);
michael@0 10
michael@0 11 withJitOptions(Opts_Ion2NoParallelCompilation, function () {
michael@0 12 var g = newGlobal();
michael@0 13 var dbg = new Debugger;
michael@0 14
michael@0 15 // Note that this *depends* on CCW scripted functions being opaque to Ion
michael@0 16 // optimization and not deoptimizing the frames below the call to toggle.
michael@0 17 g.toggle = function toggle(d) {
michael@0 18 if (d) {
michael@0 19 dbg.addDebuggee(g);
michael@0 20 var frame = dbg.getNewestFrame();
michael@0 21 assertEq(frame.implementation, "ion");
michael@0 22 // g is heavyweight but its call object is optimized out, because its
michael@0 23 // arguments and locals are unaliased.
michael@0 24 //
michael@0 25 // Calling frame.environment here should make a fake debug scope that
michael@0 26 // gets things directly from the frame. Calling frame.arguments doesn't
michael@0 27 // go through the scope object and reads directly off the frame. Assert
michael@0 28 // that the two are equal.
michael@0 29 assertEq(frame.environment.getVariable("x"), frame.arguments[1]);
michael@0 30 }
michael@0 31 };
michael@0 32
michael@0 33 g.eval("" + function f(d, x) { g(d, x); });
michael@0 34 g.eval("" + function g(d, x) {
michael@0 35 for (var i = 0; i < 200; i++);
michael@0 36 function inner() { i = 42; };
michael@0 37 toggle(d);
michael@0 38 // Use x so it doesn't get optimized out.
michael@0 39 x++;
michael@0 40 });
michael@0 41
michael@0 42 g.eval("(" + function test() {
michael@0 43 for (i = 0; i < 5; i++)
michael@0 44 f(false, 42);
michael@0 45 f(true, 42);
michael@0 46 } + ")();");
michael@0 47 });

mercurial