summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js')
-rw-r--r--js/src/jit-test/tests/debug/Memory-drainAllocationsLog-14.js47
1 files changed, 47 insertions, 0 deletions
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 000000000..dff8c8c0a
--- /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(dateNow());
+
+const root = newGlobal();
+const dbg = new Debugger(root);
+
+dbg.memory.trackingAllocationSites = true;
+root.eval("this.alloc1 = {}");
+allocTimes.push(dateNow());
+root.eval("this.alloc2 = {}");
+allocTimes.push(dateNow());
+root.eval("this.alloc3 = {}");
+allocTimes.push(dateNow());
+root.eval("this.alloc4 = {}");
+allocTimes.push(dateNow());
+
+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);