| 1 |
// Test drainAllocationsLog() and byte sizes. |
| 2 |
|
| 3 |
const root = newGlobal({newCompartment: true}); |
| 4 |
const dbg = new Debugger(); |
| 5 |
const wrappedRoot = dbg.addDebuggee(root); |
| 6 |
|
| 7 |
root.eval( |
| 8 |
` |
| 9 |
function AsmModule(stdlib, foreign, heap) { |
| 10 |
"use asm"; |
| 11 |
|
| 12 |
function test() { |
| 13 |
return 5|0; |
| 14 |
} |
| 15 |
|
| 16 |
return { test: test }; |
| 17 |
} |
| 18 |
const buf = new ArrayBuffer(1024*8); |
| 19 |
|
| 20 |
function Ctor() {} |
| 21 |
this.tests = [ |
| 22 |
{ name: "new UInt8Array(256)", fn: () => new Uint8Array(256) }, |
| 23 |
{ name: "arguments", fn: function () { return arguments; } }, |
| 24 |
{ name: "asm.js module", fn: () => AsmModule(this, {}, buf) }, |
| 25 |
{ name: "/2manyproblemz/g", fn: () => /2manyproblemz/g }, |
| 26 |
{ name: "iterator", fn: () => [1,2,3][Symbol.iterator]() }, |
| 27 |
{ name: "Error()", fn: () => Error() }, |
| 28 |
{ name: "new Ctor", fn: () => new Ctor }, |
| 29 |
{ name: "{}", fn: () => ({}) }, |
| 30 |
{ name: "new Date", fn: () => new Date }, |
| 31 |
{ name: "[1,2,3]", fn: () => [1,2,3] }, |
| 32 |
]; |
| 33 |
` |
| 34 |
); |
| 35 |
|
| 36 |
for (let { name, fn } of root.tests) { |
| 37 |
print("Test: " + name); |
| 38 |
|
| 39 |
dbg.memory.trackingAllocationSites = true; |
| 40 |
|
| 41 |
fn(); |
| 42 |
|
| 43 |
let entries = dbg.memory.drainAllocationsLog(); |
| 44 |
|
| 45 |
for (let {size} of entries) { |
| 46 |
print(" " + size + " bytes"); |
| 47 |
// We should get some kind of byte size. We aren't testing that in depth |
| 48 |
// here, it is tested pretty thoroughly in |
| 49 |
// js/src/jit-test/tests/heap-analysis/byteSize-of-object.js. |
| 50 |
assertEq(typeof size, "number"); |
| 51 |
assertEq(size > 0, true); |
| 52 |
} |
| 53 |
|
| 54 |
dbg.memory.trackingAllocationSites = false; |
| 55 |
} |