Debian Codegraph @

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

raw
1 // Test that eval-in-frame throws on accessing optimized out values.
2
3 // Use gczeal 0 to keep CGC from invalidating Ion code and causing test failures.
4 gczeal(0);
5
6 load(libdir + "jitopts.js");
7
8 if (!jitTogglesMatch(Opts_IonEagerNoOffthreadCompilation))
9 quit(0);
10
11 withJitOptions(Opts_IonEagerNoOffthreadCompilation, function() {
12 var dbgGlobal = newGlobal({newCompartment: true});
13 var dbg = new dbgGlobal.Debugger();
14 dbg.addDebuggee(this);
15
16 var warmedUp = false;
17 function check() {
18 if (warmedUp) {
19 var a = dbg.getNewestFrame().older.eval("a")
20 assertEq(a.throw.unsafeDereference().toString(),
21 "Error: variable 'a' has been optimized out");
22 }
23 }
24
25 // Test optimized-out binding in function scope.
26 function testFunctionScope() {
27 var a = 1;
28 for (var i = 0; i < 1; i++) { check(); }
29 }
30
31 // Test optimized-out binding in block scope.
32 function testBlockScope() {
33 {
34 let a = 1;
35 for (var i = 0; i < 1; i++) { check(); }
36 }
37 }
38
39 with({}) {}
40
41 testFunctionScope();
42 testBlockScope();
43
44 warmedUp = true;
45
46 testFunctionScope();
47 testBlockScope();
48 });