test_HeapSnapshot_takeCensus_04.js (1028B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that HeapSnapshot.prototype.takeCensus finds GC roots that are on the 6 // stack. 7 // 8 // Ported from js/src/jit-test/tests/debug/Memory-takeCensus-04.js 9 10 function run_test() { 11 const g = newGlobal(); 12 const dbg = new Debugger(g); 13 14 g.eval(` 15 function withAllocationMarkerOnStack(f) { 16 (function () { 17 var onStack = allocationMarker(); 18 f(); 19 }()); 20 } 21 `); 22 23 equal( 24 "AllocationMarker" in saveHeapSnapshotAndTakeCensus(dbg).objects, 25 false, 26 "There shouldn't exist any allocation markers in the census." 27 ); 28 29 let allocationMarkerCount; 30 g.withAllocationMarkerOnStack(() => { 31 const census = saveHeapSnapshotAndTakeCensus(dbg); 32 allocationMarkerCount = census.objects.AllocationMarker.count; 33 }); 34 35 equal( 36 allocationMarkerCount, 37 1, 38 "Should have one allocation marker in the census, because there " + 39 "was one on the stack." 40 ); 41 42 do_test_finished(); 43 }