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/TestVerifyJCStress.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 TestVerifyJCStress
26
* @summary Tests that we pass at least one jcstress-like test with all verification turned on
27
* @key gc
28
*
29
* @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
30
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
31
* -XX:+ShenandoahDegeneratedGC -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
32
* TestVerifyJCStress
33
*
34
* @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
35
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=passive
36
* -XX:-ShenandoahDegeneratedGC -XX:+ShenandoahVerify -XX:+VerifyObjectEquals
37
* TestVerifyJCStress
38
*/
39
40
/*
41
* @test TestVerifyJCStress
42
* @summary Tests that we pass at least one jcstress-like test with all verification turned on
43
* @key gc
44
*
45
* @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
46
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=adaptive
47
* -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
48
* TestVerifyJCStress
49
*
50
* @run main/othervm -Xmx1g -Xms1g -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
51
* -XX:+UseShenandoahGC -XX:ShenandoahGCHeuristics=compact
52
* -XX:+ShenandoahVerify -XX:+VerifyObjectEquals -XX:+ShenandoahVerifyOptoBarriers
53
* TestVerifyJCStress
54
*/
55
56
/*
57
* @test TestVerifyJCStress
58
* @summary Tests that we pass at least one jcstress-like test with all verification turned on
59
* @key gc
60
*
61
* @run main/othervm -Xmx1g -Xms1g -XX:+UnlockExperimentalVMOptions -XX:+UnlockDiagnosticVMOptions
62
* -XX:+UseShenandoahGC -XX:ShenandoahGCMode=iu
63
* -XX:+ShenandoahVerify -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers
64
* TestVerifyJCStress
65
*/
66
67
import java.util.*;
68
import java.util.concurrent.*;
69
import java.util.concurrent.locks.*;
70
71
public class TestVerifyJCStress {
72
73
public static void main(String[] args) throws Exception {
74
ExecutorService service = Executors.newFixedThreadPool(
75
2,
76
r -> {
77
Thread t = new Thread(r);
78
t.setDaemon(true);
79
return t;
80
}
81
);
82
83
for (int c = 0; c < 10000; c++) {
84
final Test[] tests = new Test[10000];
85
for (int t = 0; t < tests.length; t++) {
86
tests[t] = new Test();
87
}
88
89
Future<?> f1 = service.submit(() -> {
90
IntResult2 r = new IntResult2();
91
for (Test test : tests) {
92
test.RL_Us(r);
93
}
94
});
95
Future<?> f2 = service.submit(() -> {
96
for (Test test : tests) {
97
test.WLI_Us();
98
}
99
});
100
101
f1.get();
102
f2.get();
103
}
104
}
105
106
public static class IntResult2 {
107
int r1, r2;
108
}
109
110
public static class Test {
111
final StampedLock lock = new StampedLock();
112
113
int x, y;
114
115
public void RL_Us(IntResult2 r) {
116
StampedLock lock = this.lock;
117
long stamp = lock.readLock();
118
r.r1 = x;
119
r.r2 = y;
120
lock.unlock(stamp);
121
}
122
123
public void WLI_Us() {
124
try {
125
StampedLock lock = this.lock;
126
long stamp = lock.writeLockInterruptibly();
127
x = 1;
128
y = 2;
129
lock.unlock(stamp);
130
} catch (InterruptedException e) {
131
throw new RuntimeException(e);
132
}
133
}
134
}
135
136
}
137
138