summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/bug-1490042.js
blob: 937ae41ef389fd588f7c0595ac7363cbbeac16b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// |jit-test| --no-ion; --no-baseline; --no-blinterp; skip-if: !('gcstate' in this && hasFunction.oomAfterAllocations)

gczeal(0);

// Create a bunch of ObjectGroups with TypeNewScript attached.
const count = 1000;
let c = [];
let a = [];
for (let i = 0; i < count; i++) {
    c[i] = function() { this.a = 1; this.b = 0; this.c = 2; };
    a[i] = new c[i];
}

// Start an incremental GC and run until we're about to sweep objects.
assertEq(gcstate(), "NotActive");
gczeal(21);
startgc(1);

// Run incremental slices with simulated OOM set up to provoke OOM when sweeping
// types.
assertEq(gcstate(), "Sweep");
gczeal(10);
unsetgczeal(20);
while (gcstate() == "Sweep") {
    oomAfterAllocations(2);
    gcslice(1);
    resetOOMFailure();
}

// Ensure our type information stays alive.
let x = c.length + a.length;