blob: 85282680c05e0b1fd1286f21fb13bf2608d0dbe2 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Functions shared by gc/pretenure-*.js tests
const is64bit = getBuildConfiguration()['pointer-byte-size'] === 8;
// Count of objects that will exceed the size of the nursery.
const nurseryCount = is64bit ? 25000 : 50000;
// Count of objects that will exceed the tenured heap collection threshold.
const tenuredCount = is64bit ? 300000 : 600000;
function setupPretenureTest() {
// The test requires that baseline is enabled and is not bypassed with
// --ion-eager or similar.
let jitOptions = getJitCompilerOptions();
if (!jitOptions['baseline.enable'] ||
jitOptions['ion.warmup.trigger'] <= jitOptions['baseline.warmup.trigger']) {
print("Unsupported JIT options");
quit();
}
// Disable zeal modes that will interfere with this test.
gczeal(0);
// Restrict nursery size so we can fill it quicker, and ensure it is resized.
gcparam("minNurseryBytes", 1024 * 1024);
gcparam("maxNurseryBytes", 1024 * 1024);
// Limit allocation threshold so we trigger major GCs sooner.
gcparam("allocationThreshold", 1 /* MB */);
// Disable incremental GC so there's at most one minor GC per major GC.
gcparam("incrementalGCEnabled", false);
// Disable balanced heap limits to make the number of GCs predictable.
gcparam("balancedHeapLimitsEnabled", false);
// Force a nursery collection to apply size parameters.
let o = {};
gc();
}
function allocateObjects(count, longLived) {
let array = new Array(nurseryCount);
for (let i = 0; i < count; i++) {
let x = {x: i};
if (longLived) {
array[i % nurseryCount] = x;
} else {
array[0] = x;
}
}
return array;
}
function allocateArrays(count, longLived) {
let array = new Array(nurseryCount);
for (let i = 0; i < count; i++) {
let x = [i];
if (longLived) {
array[i % nurseryCount] = x;
} else {
array[0] = x;
}
}
return array;
}
function gcCounts() {
return { minor: gcparam("minorGCNumber"),
major: gcparam("majorGCNumber") };
}
function runTestAndCountCollections(thunk) {
let initialCounts = gcCounts();
thunk();
let finalCounts = gcCounts();
return { minor: finalCounts.minor - initialCounts.minor,
major: finalCounts.major - initialCounts.major };
}
|