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/options/TestSelectiveBarrierFlags.java
32285 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 TestSelectiveBarrierFlags
26
* @summary Test selective barrier enabling works, by aggressively compiling HelloWorld with combinations
27
* of barrier flags
28
* @library /testlibrary
29
*
30
* @run main/othervm TestSelectiveBarrierFlags -Xint
31
* @run main/othervm TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:TieredStopAtLevel=1
32
* @run main/othervm TestSelectiveBarrierFlags -Xbatch -XX:CompileThreshold=100 -XX:-TieredCompilation -XX:+IgnoreUnrecognizedVMOptions -XX:+ShenandoahVerifyOptoBarriers
33
*/
34
35
import java.util.*;
36
import java.util.concurrent.*;
37
import com.oracle.java.testlibrary.*;
38
39
public class TestSelectiveBarrierFlags {
40
41
public static void main(String[] args) throws Exception {
42
String[][] opts = {
43
new String[]{ "ShenandoahLoadRefBarrier" },
44
new String[] { "ShenandoahSATBBarrier", "ShenandoahStoreValEnqueueBarrier" },
45
new String[]{ "ShenandoahCASBarrier" },
46
new String[]{ "ShenandoahCloneBarrier" },
47
};
48
49
int size = 1;
50
for (String[] l : opts) {
51
size *= (l.length + 1);
52
}
53
54
ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
55
56
for (int c = 0; c < size; c++) {
57
int t = c;
58
59
List<String> conf = new ArrayList<>();
60
conf.addAll(Arrays.asList(args));
61
conf.add("-Xmx128m");
62
conf.add("-XX:+UnlockDiagnosticVMOptions");
63
conf.add("-XX:+UnlockExperimentalVMOptions");
64
conf.add("-XX:+UseShenandoahGC");
65
conf.add("-XX:ShenandoahGCMode=passive");
66
67
StringBuilder sb = new StringBuilder();
68
for (String[] l : opts) {
69
// Make a choice which flag to select from the group.
70
// Zero means no flag is selected from the group.
71
int choice = t % (l.length + 1);
72
for (int e = 0; e < l.length; e++) {
73
conf.add("-XX:" + ((choice == (e + 1)) ? "+" : "-") + l[e]);
74
}
75
t = t / (l.length + 1);
76
}
77
78
conf.add("TestSelectiveBarrierFlags$Test");
79
80
pool.submit(() -> {
81
try {
82
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(conf.toArray(new String[0]));
83
OutputAnalyzer output = new OutputAnalyzer(pb.start());
84
output.shouldHaveExitValue(0);
85
} catch (Exception e) {
86
e.printStackTrace();
87
System.exit(1);
88
}
89
});
90
}
91
92
pool.shutdown();
93
pool.awaitTermination(1, TimeUnit.HOURS);
94
}
95
96
public static class Test {
97
public static void main(String... args) {
98
System.out.println("HelloWorld");
99
}
100
}
101
102
}
103
104