Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/blackhole/BlackholeExperimentalUnlockTest.java
41152 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
* @run driver compiler.blackhole.BlackholeExperimentalUnlockTest
29
*/
30
31
package compiler.blackhole;
32
33
import java.io.IOException;
34
import java.util.List;
35
import java.util.Arrays;
36
import java.util.ArrayList;
37
import jdk.test.lib.Platform;
38
import jdk.test.lib.process.ProcessTools;
39
import jdk.test.lib.process.OutputAnalyzer;
40
41
public class BlackholeExperimentalUnlockTest {
42
43
private static final int CYCLES = 100_000;
44
private static final int TRIES = 10;
45
46
public static void main(String[] args) throws IOException {
47
if (args.length == 0) {
48
driver();
49
} else {
50
runner();
51
}
52
}
53
54
private static final String MSG = "Blackhole compile option is experimental and must be enabled via -XX:+UnlockExperimentalVMOptions";
55
56
private static List<String> cmdline(String[] args) {
57
List<String> r = new ArrayList();
58
r.add("-Xmx128m");
59
r.add("-Xbatch");
60
r.addAll(Arrays.asList(args));
61
r.add("compiler.blackhole.BlackholeExperimentalUnlockTest");
62
r.add("run");
63
return r;
64
}
65
66
public static void shouldFail(String... args) throws IOException {
67
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
68
OutputAnalyzer output = new OutputAnalyzer(pb.start());
69
output.shouldHaveExitValue(0);
70
output.shouldContain(MSG);
71
}
72
73
public static void shouldPass(String... args) throws IOException {
74
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline(args));
75
OutputAnalyzer output = new OutputAnalyzer(pb.start());
76
output.shouldHaveExitValue(0);
77
output.shouldNotContain(MSG);
78
}
79
80
public static void driver() throws IOException {
81
// Option is disabled by default, should fail:
82
shouldFail(
83
"-XX:CompileCommand=quiet",
84
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
85
);
86
shouldFail(
87
"-XX:CompileCommand=quiet",
88
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
89
);
90
91
// Option should be enabled by UnlockExperimentalVMOptions
92
shouldPass(
93
"-XX:+UnlockExperimentalVMOptions",
94
"-XX:CompileCommand=quiet",
95
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
96
);
97
shouldPass(
98
"-XX:+UnlockExperimentalVMOptions",
99
"-XX:CompileCommand=quiet",
100
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
101
);
102
103
// Should be able to shun the warning
104
shouldPass(
105
"-XX:-PrintWarnings",
106
"-XX:CompileCommand=quiet",
107
"-XX:CompileCommand=option,compiler/blackhole/BlackholeTarget.bh_*,Blackhole"
108
);
109
shouldPass(
110
"-XX:-PrintWarnings",
111
"-XX:CompileCommand=quiet",
112
"-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*"
113
);
114
}
115
116
public static void runner() {
117
for (int t = 0; t < TRIES; t++) {
118
run();
119
}
120
}
121
122
public static void run() {
123
for (int c = 0; c < CYCLES; c++) {
124
BlackholeTarget.bh_s_int_1(c);
125
}
126
}
127
128
}
129
130