Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/shenandoah/TestSieveObjects.java
32284 views
1
/*
2
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved.
3
*
4
* This code is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 2 only, as
6
* published by the Free Software Foundation.
7
*
8
* This code is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11
* version 2 for more details (a copy is included in the LICENSE file that
12
* accompanied this code).
13
*
14
* You should have received a copy of the GNU General Public License version
15
* 2 along with this work; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*
18
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19
* or visit www.oracle.com if you need additional information or have any
20
* questions.
21
*
22
*/
23
24
/*
25
* @test TestSieveObjects
26
* @summary Acceptance tests: collector can deal with retained objects
27
* @key gc
28
*
29
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
30
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
31
* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify
32
* TestSieveObjects
33
*
34
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
35
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
36
* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify
37
* TestSieveObjects
38
*
39
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
40
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
41
* -XX:+ShenandoahDegeneratedGC
42
* TestSieveObjects
43
*
44
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
45
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
46
* -XX:-ShenandoahDegeneratedGC
47
* TestSieveObjects
48
*/
49
50
/*
51
* @test TestSieveObjects
52
* @summary Acceptance tests: collector can deal with retained objects
53
* @key gc
54
*
55
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
56
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
57
* -XX:+ShenandoahOOMDuringEvacALot
58
* TestSieveObjects
59
*
60
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
61
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
62
* -XX:+ShenandoahAllocFailureALot
63
* TestSieveObjects
64
*
65
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
66
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=aggressive
67
* TestSieveObjects
68
*/
69
70
/*
71
* @test TestSieveObjects
72
* @summary Acceptance tests: collector can deal with retained objects
73
* @key gc
74
*
75
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
76
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
77
* -XX:+ShenandoahVerify
78
* TestSieveObjects
79
*
80
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
81
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
82
* TestSieveObjects
83
*
84
*/
85
86
/*
87
* @test TestSieveObjects
88
* @summary Acceptance tests: collector can deal with retained objects
89
* @key gc
90
*
91
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
92
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=static
93
* TestSieveObjects
94
*/
95
96
/*
97
* @test TestSieveObjects
98
* @summary Acceptance tests: collector can deal with retained objects
99
* @key gc
100
*
101
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
102
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
103
* TestSieveObjects
104
*/
105
106
/*
107
* @test TestSieveObjects
108
* @summary Acceptance tests: collector can deal with retained objects
109
* @key gc
110
*
111
* @run main/othervm/timeout=240 -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
112
* -XX:+UseShenandoahGC
113
* -XX:-UseTLAB -XX:+ShenandoahVerify
114
* TestSieveObjects
115
*/
116
117
/*
118
* @test TestSieveObjects
119
* @summary Acceptance tests: collector can deal with retained objects
120
* @key gc
121
*
122
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
123
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
124
* -XX:+ShenandoahOOMDuringEvacALot
125
* TestSieveObjects
126
*
127
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
128
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
129
* -XX:+ShenandoahAllocFailureALot
130
* TestSieveObjects
131
*
132
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
133
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu -XX:ShenandoahGCHeuristics=aggressive
134
* TestSieveObjects
135
*/
136
137
/*
138
* @test TestSieveObjects
139
* @summary Acceptance tests: collector can deal with retained objects
140
* @key gc
141
*
142
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
143
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
144
* -XX:+ShenandoahVerify
145
* TestSieveObjects
146
*
147
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
148
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
149
* TestSieveObjects
150
*/
151
152
import java.util.concurrent.ThreadLocalRandom;
153
154
public class TestSieveObjects {
155
156
static final int COUNT = 100_000_000;
157
static final int WINDOW = 1_000_000;
158
static final int PAYLOAD = 100;
159
160
static final MyObject[] arr = new MyObject[WINDOW];
161
162
public static void main(String[] args) throws Exception {
163
int rIdx = 0;
164
for (int c = 0; c < COUNT; c++) {
165
MyObject v = arr[rIdx];
166
if (v != null) {
167
if (v.x != rIdx) {
168
throw new IllegalStateException("Illegal value at index " + rIdx + ": " + v.x);
169
}
170
if (ThreadLocalRandom.current().nextInt(1000) > 100) {
171
arr[rIdx] = null;
172
}
173
} else {
174
if (ThreadLocalRandom.current().nextInt(1000) > 500) {
175
arr[rIdx] = new MyObject(rIdx);
176
}
177
}
178
rIdx++;
179
if (rIdx >= WINDOW) {
180
rIdx = 0;
181
}
182
}
183
}
184
185
public static class MyObject {
186
public int x;
187
public byte[] payload;
188
189
public MyObject(int x) {
190
this.x = x;
191
this.payload = new byte[PAYLOAD];
192
}
193
}
194
195
}
196
197