Memory-takeCensus-11.js (1851B)
1 // |jit-test| --baseline-offthread-compile=off; skip-if: isLcovEnabled() 2 3 // NOTE: Code coverage keeps top-level script alive even if normally it would be 4 // GC'd. Skip this test in that case. For the same reason, offthread 5 // baseline compilation must be disabled. 6 7 // Check byte counts produced by takeCensus. 8 9 const g = newGlobal({newCompartment: true }); 10 g.evaluate("setJitCompilerOption('ion.warmup.trigger', 1000)", 11 { 12 forceFullParse: true, 13 }); 14 15 const dbg = new Debugger(g); 16 17 g.evaluate("function one() {}", 18 { 19 fileName: "one.js", 20 forceFullParse: true, 21 }); 22 g.evaluate(`function two1() {} 23 function two2() {}`, 24 { 25 fileName: "two.js", 26 forceFullParse: true, 27 }); 28 g.evaluate(`function three1() {} 29 function three2() {} 30 function three3() {}`, 31 { 32 fileName: "three.js", 33 forceFullParse: true, 34 }); 35 36 const report = dbg.memory.takeCensus({ 37 breakdown: { 38 by: "coarseType", 39 scripts: { 40 by: "filename", 41 then: { by: "count", count: true, bytes: false }, 42 noFilename: { 43 by: "internalType", 44 then: { by: "count", count: true, bytes: false } 45 } 46 }, 47 48 // Not really interested in these, but they're here for completeness. 49 objects: { by: "count", count: true, byte: false }, 50 strings: { by: "count", count: true, byte: false }, 51 other: { by: "count", count: true, byte: false }, 52 } 53 }); 54 55 print(JSON.stringify(report, null, 4)); 56 57 assertEq(report.scripts["one.js"].count, 1); 58 assertEq(report.scripts["two.js"].count, 2); 59 assertEq(report.scripts["three.js"].count, 3); 60 61 const noFilename = report.scripts.noFilename; 62 assertEq(!!noFilename, true); 63 assertEq(typeof noFilename, "object");