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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Tests that we can reflect optimized out values.
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 // x is unused and should be elided.
michael@0 23 assertEq(frame.environment.getVariable("x").optimizedOut, true);
michael@0 24 assertEq(frame.arguments[1].optimizedOut, true);
michael@0 25 }
michael@0 26 };
michael@0 27
michael@0 28 g.eval("" + function f(d, x) { "use strict"; g(d, x); });
michael@0 29
michael@0 30 g.eval("" + function g(d, x) {
michael@0 31 "use strict";
michael@0 32 for (var i = 0; i < 200; i++);
michael@0 33 // Hack to prevent inlining.
michael@0 34 function inner() { i = 42; };
michael@0 35 toggle(d);
michael@0 36 });
michael@0 37
michael@0 38 g.eval("(" + function test() {
michael@0 39 for (i = 0; i < 5; i++)
michael@0 40 f(false, 42);
michael@0 41 f(true, 42);
michael@0 42 } + ")();");
michael@0 43 });

mercurial