Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/intrinsics/IntrinsicAvailableTest.java
41152 views
1
/*
2
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. 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
* @bug 8130832
27
* @modules java.base/jdk.internal.misc
28
* @library /test/lib /
29
*
30
* @build sun.hotspot.WhiteBox
31
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
32
* @run main/othervm -Xbootclasspath/a:.
33
* -XX:+UnlockDiagnosticVMOptions
34
* -XX:+WhiteBoxAPI
35
* -XX:+UseCRC32Intrinsics
36
* compiler.intrinsics.IntrinsicAvailableTest
37
* @run main/othervm -Xbootclasspath/a:.
38
* -XX:+UnlockDiagnosticVMOptions
39
* -XX:+WhiteBoxAPI
40
* -XX:-UseCRC32Intrinsics
41
* compiler.intrinsics.IntrinsicAvailableTest
42
* @run main/othervm -Xbootclasspath/a:.
43
* -XX:+UnlockDiagnosticVMOptions
44
* -XX:+WhiteBoxAPI
45
* -XX:ControlIntrinsic=+_updateCRC32
46
* -XX:-UseCRC32Intrinsics
47
* compiler.intrinsics.IntrinsicAvailableTest
48
* @run main/othervm -Xbootclasspath/a:.
49
* -XX:+UnlockDiagnosticVMOptions
50
* -XX:+WhiteBoxAPI
51
* -XX:ControlIntrinsic=-_updateCRC32
52
* -XX:+UseCRC32Intrinsics
53
* compiler.intrinsics.IntrinsicAvailableTest
54
*
55
* @run main/othervm -Xbootclasspath/a:.
56
* -XX:+UnlockDiagnosticVMOptions
57
* -XX:+WhiteBoxAPI
58
* -XX:ControlIntrinsic=+_updateCRC32
59
* -XX:+UseCRC32Intrinsics
60
* compiler.intrinsics.IntrinsicAvailableTest
61
*/
62
63
64
package compiler.intrinsics;
65
66
import compiler.whitebox.CompilerWhiteBoxTest;
67
import jdk.test.lib.Platform;
68
69
import java.lang.reflect.Executable;
70
import java.util.concurrent.Callable;
71
72
public class IntrinsicAvailableTest extends CompilerWhiteBoxTest {
73
74
public IntrinsicAvailableTest(IntrinsicAvailableTestTestCase testCase) {
75
super(testCase);
76
}
77
78
public static class IntrinsicAvailableTestTestCase implements TestCase {
79
80
public String name() {
81
return "IntrinsicAvailableTestTestCase";
82
}
83
84
public Executable getExecutable() {
85
// Using a single method to test the
86
// WhiteBox.isIntrinsicAvailable(Executable method, int compLevel)
87
// call for the compilation level corresponding to both the C1 and C2
88
// compiler keeps the current test simple.
89
//
90
// The tested method is java.util.zip.CRC32.update(int, int) because
91
// both C1 and C2 define an intrinsic for the method and
92
// the UseCRC32Intrinsics flag can be used to enable/disable
93
// intrinsification of the method in both product and fastdebug
94
// builds.
95
try {
96
return Class.forName("java.util.zip.CRC32").getDeclaredMethod("update", int.class, int.class);
97
} catch (NoSuchMethodException e) {
98
throw new RuntimeException("Test bug, method unavailable. " + e);
99
} catch (ClassNotFoundException e) {
100
throw new RuntimeException("Test bug, class unavailable. " + e);
101
}
102
}
103
104
public Callable<Integer> getCallable() {
105
return null;
106
}
107
108
public boolean isOsr() {
109
return false;
110
}
111
112
}
113
114
protected void checkIntrinsicForCompilationLevel(Executable method, int compLevel) throws Exception {
115
boolean intrinsicEnabled = true;
116
String controlIntrinsic = getVMOption("ControlIntrinsic", "");
117
118
if (controlIntrinsic.contains("+_updateCRC32")) {
119
intrinsicEnabled = true;
120
} else if (controlIntrinsic.contains("-_updateCRC32")) {
121
intrinsicEnabled = false;
122
}
123
124
intrinsicEnabled &= Boolean.valueOf(getVMOption("UseCRC32Intrinsics"));
125
126
boolean intrinsicAvailable = WHITE_BOX.isIntrinsicAvailable(method,
127
compLevel);
128
129
String intrinsicEnabledMessage = intrinsicEnabled ? "enabled" : "disabled";
130
String intrinsicAvailableMessage = intrinsicAvailable ? "available" : "not available";
131
132
if (intrinsicEnabled == intrinsicAvailable) {
133
System.out.println("Expected result: intrinsic for java.util.zip.CRC32.update() is " +
134
intrinsicEnabledMessage + " and intrinsic is " + intrinsicAvailableMessage +
135
" at compilation level " + compLevel);
136
} else {
137
throw new RuntimeException("Unexpected result: intrinsic for java.util.zip.CRC32.update() is " +
138
intrinsicEnabledMessage + " but intrinsic is " + intrinsicAvailableMessage +
139
" at compilation level " + compLevel);
140
}
141
}
142
143
public void test() throws Exception {
144
Executable intrinsicMethod = testCase.getExecutable();
145
if (Platform.isServer() && !Platform.isEmulatedClient() && (TIERED_STOP_AT_LEVEL == COMP_LEVEL_FULL_OPTIMIZATION)) {
146
if (TIERED_COMPILATION) {
147
checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
148
}
149
// Dont bother check JVMCI compiler - returns false on all intrinsics.
150
if (!Boolean.valueOf(getVMOption("UseJVMCICompiler"))) {
151
checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION);
152
}
153
} else {
154
checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
155
}
156
}
157
158
public static void main(String args[]) throws Exception {
159
new IntrinsicAvailableTest(new IntrinsicAvailableTestTestCase()).test();
160
}
161
}
162
163