Debian Codegraph @

js/src/jit-test/tests/debug/Memory-takeCensus-12.js

raw
1 // Sanity test that we can accumulate matching individuals in a bucket.
2
3 var g = newGlobal({newCompartment: true});
4 var dbg = new Debugger(g);
5
6 var bucket = { by: "bucket" };
7 var count = { by: "count", count: true, bytes: false };
8
9 var all = dbg.memory.takeCensus({ breakdown: bucket });
10 var allCount = dbg.memory.takeCensus({ breakdown: count }).count;
11
12 var coarse = dbg.memory.takeCensus({
13 breakdown: {
14 by: "coarseType",
15 objects: bucket,
16 strings: bucket,
17 scripts: bucket,
18 other: bucket
19 }
20 });
21 var coarseCount = dbg.memory.takeCensus({
22 breakdown: {
23 by: "coarseType",
24 objects: count,
25 strings: count,
26 scripts: count,
27 other: count
28 }
29 });
30
31 assertEq(all.length > 0, true);
32 assertEq(all.length, allCount);
33
34 assertEq(coarse.objects.length > 0, true);
35 assertEq(coarseCount.objects.count, coarse.objects.length);
36
37 assertEq(coarse.strings.length > 0, true);
38 assertEq(coarseCount.strings.count, coarse.strings.length);
39
40 assertEq(coarse.scripts.length > 0, true);
41 assertEq(coarseCount.scripts.count, coarse.scripts.length);
42
43 assertEq(coarse.other.length > 0, true);
44 assertEq(coarseCount.other.count, coarse.other.length);
45
46 assertEq(all.length >= coarse.objects.length, true);
47 assertEq(all.length >= coarse.strings.length, true);
48 assertEq(all.length >= coarse.scripts.length, true);
49 assertEq(all.length >= coarse.other.length, true);
50
51 function assertIsIdentifier(id) {
52 assertEq(id, Math.floor(id));
53 assertEq(id > 0, true);
54 assertEq(id <= Math.pow(2, 48), true);
55 }
56
57 all.forEach(assertIsIdentifier);
58 coarse.objects.forEach(assertIsIdentifier);
59 coarse.strings.forEach(assertIsIdentifier);
60 coarse.scripts.forEach(assertIsIdentifier);
61 coarse.other.forEach(assertIsIdentifier);