summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/elements-post-write-barrier.js
blob: 04249eb727dc0745e1a7b49cc3393c2d6c669e61 (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
gczeal(12);

var length = 10000;
var array = new Array(length);
array.fill(null);

// Promote the array to the tenured heap, if it isn't already there.
minorgc();

for (var i = 0; i < length; i++) {
  // Exercise that barrier with some fresh nursery object references!
  array[i] = {};
}

minorgc();

for (var i = length; i > 0; i--) {
  array[i - 1] = {};
}

minorgc();

for (var i = 0; i < length; i++) {
  array[Math.floor(Math.random() * length)] = {};
}

gc();