Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/blackhole/BlackholeIntrinsicTest.java
41149 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.BlackholeIntrinsicTest
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 java.util.LinkedHashMap;
38
import java.util.Map;
39
40
import jdk.test.lib.Platform;
41
import jdk.test.lib.process.ProcessTools;
42
import jdk.test.lib.process.OutputAnalyzer;
43
44
public class BlackholeIntrinsicTest {
45
46
private static final Map<String, Runnable> TESTS;
47
48
static {
49
TESTS = new LinkedHashMap<>();
50
TESTS.put("bh_s_boolean_0", BlackholeIntrinsicTest::test_boolean_0);
51
TESTS.put("bh_s_byte_0", BlackholeIntrinsicTest::test_byte_0);
52
TESTS.put("bh_s_char_0", BlackholeIntrinsicTest::test_char_0);
53
TESTS.put("bh_s_short_0", BlackholeIntrinsicTest::test_short_0);
54
TESTS.put("bh_s_int_0", BlackholeIntrinsicTest::test_int_0);
55
TESTS.put("bh_s_float_0", BlackholeIntrinsicTest::test_float_0);
56
TESTS.put("bh_s_long_0", BlackholeIntrinsicTest::test_long_0);
57
TESTS.put("bh_s_double_0", BlackholeIntrinsicTest::test_double_0);
58
TESTS.put("bh_s_Object_0", BlackholeIntrinsicTest::test_Object_0);
59
60
TESTS.put("bh_s_boolean_1", BlackholeIntrinsicTest::test_boolean_1);
61
TESTS.put("bh_s_byte_1", BlackholeIntrinsicTest::test_byte_1);
62
TESTS.put("bh_s_char_1", BlackholeIntrinsicTest::test_char_1);
63
TESTS.put("bh_s_short_1", BlackholeIntrinsicTest::test_short_1);
64
TESTS.put("bh_s_int_1", BlackholeIntrinsicTest::test_int_1);
65
TESTS.put("bh_s_float_1", BlackholeIntrinsicTest::test_float_1);
66
TESTS.put("bh_s_long_1", BlackholeIntrinsicTest::test_long_1);
67
TESTS.put("bh_s_double_1", BlackholeIntrinsicTest::test_double_1);
68
TESTS.put("bh_s_Object_1", BlackholeIntrinsicTest::test_Object_1);
69
70
TESTS.put("bh_s_boolean_2", BlackholeIntrinsicTest::test_boolean_2);
71
TESTS.put("bh_s_byte_2", BlackholeIntrinsicTest::test_byte_2);
72
TESTS.put("bh_s_char_2", BlackholeIntrinsicTest::test_char_2);
73
TESTS.put("bh_s_short_2", BlackholeIntrinsicTest::test_short_2);
74
TESTS.put("bh_s_int_2", BlackholeIntrinsicTest::test_int_2);
75
TESTS.put("bh_s_float_2", BlackholeIntrinsicTest::test_float_2);
76
TESTS.put("bh_s_long_2", BlackholeIntrinsicTest::test_long_2);
77
TESTS.put("bh_s_double_2", BlackholeIntrinsicTest::test_double_2);
78
TESTS.put("bh_s_Object_2", BlackholeIntrinsicTest::test_Object_2);
79
}
80
81
private static final int CYCLES = 100_000;
82
private static final int TRIES = 10;
83
84
public static void main(String[] args) throws IOException {
85
if (args.length == 0) {
86
driver();
87
} else {
88
test(args[0]);
89
}
90
}
91
92
public static void driver() throws IOException {
93
for (String test : TESTS.keySet()) {
94
check(test, "-XX:TieredStopAtLevel=1");
95
check(test, "-XX:-TieredCompilation");
96
if (Platform.is64bit()) {
97
check(test, "-XX:-UseCompressedOops", "-XX:TieredStopAtLevel=1");
98
check(test, "-XX:-UseCompressedOops", "-XX:-TieredCompilation");
99
}
100
}
101
}
102
103
private static void test(String test) {
104
Runnable r = TESTS.get(test);
105
if (r == null) {
106
throw new IllegalArgumentException("Cannot find test " + test);
107
}
108
for (int t = 0; t < TRIES; t++) {
109
r.run();
110
}
111
}
112
113
public static void check(String test, String... args) throws IOException {
114
List<String> cmdline = new ArrayList();
115
cmdline.add("-Xmx128m");
116
cmdline.add("-Xbatch");
117
cmdline.add("-XX:+UnlockDiagnosticVMOptions");
118
cmdline.add("-XX:+AbortVMOnCompilationFailure");
119
cmdline.add("-XX:+PrintCompilation");
120
cmdline.add("-XX:+PrintInlining");
121
cmdline.add("-XX:+UnlockExperimentalVMOptions");
122
cmdline.add("-XX:CompileCommand=blackhole,compiler/blackhole/BlackholeTarget.bh_*");
123
cmdline.addAll(Arrays.asList(args));
124
cmdline.add("compiler.blackhole.BlackholeIntrinsicTest");
125
cmdline.add(test);
126
127
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmdline);
128
OutputAnalyzer output = new OutputAnalyzer(pb.start());
129
output.shouldHaveExitValue(0);
130
output.stderrShouldBeEmpty();
131
output.stdoutShouldMatch("compiler.blackhole.BlackholeTarget::" + test + ".*intrinsic.*");
132
}
133
134
private static void test_boolean_0() {
135
for (int c = 0; c < CYCLES; c++) {
136
BlackholeTarget.bh_s_boolean_0();
137
}
138
}
139
140
private static void test_byte_0() {
141
for (int c = 0; c < CYCLES; c++) {
142
BlackholeTarget.bh_s_byte_0();
143
}
144
}
145
146
private static void test_char_0() {
147
for (int c = 0; c < CYCLES; c++) {
148
BlackholeTarget.bh_s_char_0();
149
}
150
}
151
152
private static void test_short_0() {
153
for (int c = 0; c < CYCLES; c++) {
154
BlackholeTarget.bh_s_short_0();
155
}
156
}
157
158
private static void test_int_0() {
159
for (int c = 0; c < CYCLES; c++) {
160
BlackholeTarget.bh_s_int_0();
161
}
162
}
163
164
private static void test_float_0() {
165
for (int c = 0; c < CYCLES; c++) {
166
BlackholeTarget.bh_s_float_0();
167
}
168
}
169
170
private static void test_long_0() {
171
for (int c = 0; c < CYCLES; c++) {
172
BlackholeTarget.bh_s_long_0();
173
}
174
}
175
176
private static void test_double_0() {
177
for (int c = 0; c < CYCLES; c++) {
178
BlackholeTarget.bh_s_double_0();
179
}
180
}
181
182
private static void test_Object_0() {
183
for (int c = 0; c < CYCLES; c++) {
184
BlackholeTarget.bh_s_Object_0();
185
}
186
}
187
188
private static void test_boolean_1() {
189
for (int c = 0; c < CYCLES; c++) {
190
BlackholeTarget.bh_s_boolean_1((c & 0x1) == 0);
191
}
192
}
193
194
private static void test_byte_1() {
195
for (int c = 0; c < CYCLES; c++) {
196
BlackholeTarget.bh_s_byte_1((byte)c);
197
}
198
}
199
200
private static void test_char_1() {
201
for (int c = 0; c < CYCLES; c++) {
202
BlackholeTarget.bh_s_char_1((char)c);
203
}
204
}
205
206
private static void test_short_1() {
207
for (int c = 0; c < CYCLES; c++) {
208
BlackholeTarget.bh_s_short_1((short)c);
209
}
210
}
211
212
private static void test_int_1() {
213
for (int c = 0; c < CYCLES; c++) {
214
BlackholeTarget.bh_s_int_1(c);
215
}
216
}
217
218
private static void test_float_1() {
219
for (int c = 0; c < CYCLES; c++) {
220
BlackholeTarget.bh_s_float_1(c);
221
}
222
}
223
224
private static void test_long_1() {
225
for (int c = 0; c < CYCLES; c++) {
226
BlackholeTarget.bh_s_long_1(c);
227
}
228
}
229
230
private static void test_double_1() {
231
for (int c = 0; c < CYCLES; c++) {
232
BlackholeTarget.bh_s_double_1(c);
233
}
234
}
235
236
private static void test_Object_1() {
237
for (int c = 0; c < CYCLES; c++) {
238
Object o = new Object();
239
BlackholeTarget.bh_s_Object_1(o);
240
}
241
}
242
243
private static void test_boolean_2() {
244
for (int c = 0; c < CYCLES; c++) {
245
BlackholeTarget.bh_s_boolean_2((c & 0x1) == 0, (c & 0x2) == 0);
246
}
247
}
248
249
private static void test_byte_2() {
250
for (int c = 0; c < CYCLES; c++) {
251
BlackholeTarget.bh_s_byte_2((byte)c, (byte)(c + 1));
252
}
253
}
254
255
private static void test_char_2() {
256
for (int c = 0; c < CYCLES; c++) {
257
BlackholeTarget.bh_s_char_2((char)c, (char)(c + 1));
258
}
259
}
260
261
private static void test_short_2() {
262
for (int c = 0; c < CYCLES; c++) {
263
BlackholeTarget.bh_s_short_2((short)c, (short)(c + 1));
264
}
265
}
266
267
private static void test_int_2() {
268
for (int c = 0; c < CYCLES; c++) {
269
BlackholeTarget.bh_s_int_2(c, c + 1);
270
}
271
}
272
273
private static void test_float_2() {
274
for (int c = 0; c < CYCLES; c++) {
275
BlackholeTarget.bh_s_float_2(c, c + 1);
276
}
277
}
278
279
private static void test_long_2() {
280
for (int c = 0; c < CYCLES; c++) {
281
BlackholeTarget.bh_s_long_2(c, c + 1);
282
}
283
}
284
285
private static void test_double_2() {
286
for (int c = 0; c < CYCLES; c++) {
287
BlackholeTarget.bh_s_double_2(c, c + 1);
288
}
289
}
290
291
private static void test_Object_2() {
292
for (int c = 0; c < CYCLES; c++) {
293
Object o1 = new Object();
294
Object o2 = new Object();
295
BlackholeTarget.bh_s_Object_2(o1, o2);
296
}
297
}
298
}
299
300