tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Memory-takeCensus-04.js (821B)


      1 // Test that Debugger.Memory.prototype.takeCensus finds GC roots that are on the
      2 // stack.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = new Debugger(g);
      6 
      7 g.eval(`
      8  function withAllocationMarkerOnStack(f) {
      9    (function () {
     10      var onStack = allocationMarker();
     11      f();
     12      return onStack; // To prevent the JIT from optimizing out onStack.
     13    }())
     14  }
     15 `);
     16 
     17 assertEq("AllocationMarker" in dbg.memory.takeCensus().objects, false,
     18         "There shouldn't exist any allocation markers in the census.");
     19 
     20 var allocationMarkerCount;
     21 g.withAllocationMarkerOnStack(() => {
     22  allocationMarkerCount = dbg.memory.takeCensus().objects.AllocationMarker.count;
     23 });
     24 
     25 assertEq(allocationMarkerCount, 1,
     26         "Should have one allocation marker in the census, because there " +
     27         "was one on the stack.");