Debian Codegraph @

js/src/jit-test/tests/debug/Memory-drainAllocationsLog-08.js

raw
1 // Test retrieving the log multiple times.
2
3 const root = newGlobal({newCompartment: true});
4 const dbg = new Debugger();
5 dbg.addDebuggee(root)
6
7 root.eval([
8 "this.allocs = [];",
9 "this.doFirstAlloc = " + function () {
10 this.allocs.push({}); this.firstAllocLine = Error().lineNumber;
11 },
12 "this.doSecondAlloc = " + function () {
13 this.allocs.push(new Object()); this.secondAllocLine = Error().lineNumber;
14 }
15 ].join("\n"));
16
17 dbg.memory.trackingAllocationSites = true;
18
19 root.doFirstAlloc();
20 let allocs1 = dbg.memory.drainAllocationsLog();
21 root.doSecondAlloc();
22 let allocs2 = dbg.memory.drainAllocationsLog();
23
24 let allocs1Lines = allocs1.filter(x => !!x.frame).map(x => x.frame.line);
25 assertEq(allocs1Lines.indexOf(root.firstAllocLine) != -1, true);
26 assertEq(allocs1Lines.indexOf(root.secondAllocLine) == -1, true);
27
28 let allocs2Lines = allocs2.filter(x => !!x.frame).map(x => x.frame.line);
29 assertEq(allocs2Lines.indexOf(root.secondAllocLine) != -1, true);
30 assertEq(allocs2Lines.indexOf(root.firstAllocLine) == -1, true);