Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/hotspot/jtreg/compiler/blackhole/BlackholeExistingIntrinsicWarningTest.java
64475 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.BlackholeExistingIntrinsicWarningTest
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.process.ProcessTools;
39
import jdk.test.lib.process.OutputAnalyzer;
40
41
public class BlackholeExistingIntrinsicWarningTest {
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 =
55
"Blackhole compile option only works for methods that do not have intrinsic set: java.lang.Thread.onSpinWait()V, _onSpinWait";
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.BlackholeExistingIntrinsicWarningTest");
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
// Should print the warning
83
shouldFail(
84
"-XX:+UnlockExperimentalVMOptions",
85
"-XX:CompileCommand=quiet",
86
"-XX:CompileCommand=blackhole,java/lang/Thread.onSpinWait"
87
);
88
shouldFail(
89
"-XX:+UnlockExperimentalVMOptions",
90
"-XX:CompileCommand=quiet",
91
"-XX:CompileCommand=option,java/lang/Thread.onSpinWait,Blackhole"
92
);
93
94
// Should be able to shun the warning
95
shouldPass(
96
"-XX:-PrintWarnings",
97
"-XX:+UnlockExperimentalVMOptions",
98
"-XX:CompileCommand=quiet",
99
"-XX:CompileCommand=blackhole,java/lang/Thread.onSpinWait"
100
);
101
shouldPass(
102
"-XX:-PrintWarnings",
103
"-XX:+UnlockExperimentalVMOptions",
104
"-XX:CompileCommand=quiet",
105
"-XX:CompileCommand=option,java/lang/Thread.onSpinWait,Blackhole"
106
);
107
}
108
109
public static void runner() {
110
for (int t = 0; t < TRIES; t++) {
111
run();
112
}
113
}
114
115
public static void run() {
116
for (int c = 0; c < CYCLES; c++) {
117
Thread.onSpinWait();
118
}
119
}
120
121
}
122
123