From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/debug/Memory-drainAllocationsLog-14.js | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js (limited to 'js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js') diff --git a/js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js b/js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js new file mode 100644 index 0000000000..39b2674c31 --- /dev/null +++ b/js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js @@ -0,0 +1,47 @@ +// Test that drainAllocationsLog returns some timestamps. + +load(libdir + 'asserts.js'); + +var allocTimes = []; + +allocTimes.push(timeSinceCreation()); + +const root = newGlobal({newCompartment: true}); +const dbg = new Debugger(root); + +dbg.memory.trackingAllocationSites = true; +root.eval("this.alloc1 = {}"); +allocTimes.push(timeSinceCreation()); +root.eval("this.alloc2 = {}"); +allocTimes.push(timeSinceCreation()); +root.eval("this.alloc3 = {}"); +allocTimes.push(timeSinceCreation()); +root.eval("this.alloc4 = {}"); +allocTimes.push(timeSinceCreation()); + +allocs = dbg.memory.drainAllocationsLog(); +assertEq(allocs.length >= 4, true); +assertEq(allocs[0].timestamp >= allocTimes[0], true); +var seenAlloc = 0; +var lastIndexSeenAllocIncremented = 0; +for (i = 1; i < allocs.length; ++i) { + assertEq(allocs[i].timestamp >= allocs[i - 1].timestamp, true); + // It isn't possible to exactly correlate the entries in the + // allocs array with the entries in allocTimes, because we can't + // control exactly how many allocations are done during the course + // of a given eval. However, we can assume that there is some + // allocation recorded after each entry in allocTimes. So, we + // track the allocTimes entry we've passed, and then after the + // loop assert that we've seen them all. We also assert that a + // non-zero number of allocations has happened since the last seen + // increment. + while (seenAlloc < allocTimes.length + && allocs[i].timestamp >= allocTimes[seenAlloc]) { + assertEq(i - lastIndexSeenAllocIncremented > 0, true); + lastIndexSeenAllocIncremented = i; + ++seenAlloc; + } +} +// There should be one entry left in allocTimes, because we recorded a +// time after the last possible allocation in the array. +assertEq(seenAlloc, allocTimes.length -1); -- cgit v1.2.3