Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java
64474 views
1
/*
2
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/**
25
* @test
26
* @library /test/lib /
27
* @requires vm.flagless
28
* @requires vm.compMode != "Xint"
29
* @run driver compiler.blackhole.BlackholeExperimentalUnlockTest
30
*/
31
32
package compiler.blackhole;
33
34
import java.io.IOException;
35
import java.util.List;
36
import java.util.Arrays;
37
import java.util.ArrayList;
38
import jdk.test.lib.Platform;
39
import jdk.test.lib.process.ProcessTools;
40
import jdk.test.lib.process.OutputAnalyzer;
41
42
public class BlackholeExperimentalUnlockTest {
43
44
private static final int CYCLES = 100_000;
45
private static final int TRIES = 10;
46
47
public static void main(String[] args) throws IOException {
48
if (args.length == 0) {
49
driver();
50
} else {
51
runner();
52
}
53
}
54
55
private static final String MSG = "Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions";
56
57
private static List<String> cmdline(String[] args) {
58
List<String> r = new ArrayList();
59
r.add("-Xmx128m");
60
r.add("-Xbatch");
61
r.addAll(Arrays.asList(args));
62
r.add("compiler.blackhole.BlackholeExperimentalUnlockTest");
63
r.add("run");
64
return r;
65
}
66
67
public static void shouldFail(String... args) throws IOException {
68
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
69
OutputAnalyzer output = new OutputAnalyzer(pb.start());
70
output.shouldHaveExitValue(0);
71
output.shouldContain(MSG);
72
}
73
74
public static void shouldPass(String... args) throws IOException {
75
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
76
OutputAnalyzer output = new OutputAnalyzer(pb.start());
77
output.shouldHaveExitValue(0);
78
output.shouldNotContain(MSG);
79
}
80
81
public static void driver() throws IOException {
82
// Option is disabled by default, should fail:
83
shouldFail(
84
"-XX:CompileCommand=quiet",
85
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
86
);
87
shouldFail(
88
"-XX:CompileCommand=quiet",
89
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
90
);
91
92
// Option should be enabled by UnlockExperimentalVMOptions
93
shouldPass(
94
"-XX:+UnlockExperimentalVMOptions",
95
"-XX:CompileCommand=quiet",
96
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
97
);
98
shouldPass(
99
"-XX:+UnlockExperimentalVMOptions",
100
"-XX:CompileCommand=quiet",
101
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
102
);
103
104
// Should be able to shun the warning
105
shouldPass(
106
"-XX:-PrintWarnings",
107
"-XX:CompileCommand=quiet",
108
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
109
);
110
shouldPass(
111
"-XX:-PrintWarnings",
112
"-XX:CompileCommand=quiet",
113
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
114
);
115
}
116
117
public static void runner() {
118
for (int t = 0; t < TRIES; t++) {
119
run();
120
}
121
}
122
123
public static void run() {
124
for (int c = 0; c < CYCLES; c++) {
125
BlackholeTarget.bh_s_int_1(c);
126
}
127
}
128
129
}
130
131