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 import java.lang.reflect.Executable;
24 import java.util.concurrent.Callable;
25 import java.util.Objects;
26 import compiler.whitebox.CompilerWhiteBoxTest;
27 /*
28 * @test
29 * @bug 8130832
30 * @library /testlibrary /test/lib /compiler/whitebox /compiler/testlibrary /
31 * @build IntrinsicAvailableTest
32 * @run main ClassFileInstaller sun.hotspot.WhiteBox
33 * sun.hotspot.WhiteBox$WhiteBoxPermission
34 * @run main/othervm -Xbootclasspath/a:.
35 * -XX:+UnlockDiagnosticVMOptions
36 * -XX:+WhiteBoxAPI
37 * -XX:+UseCRC32Intrinsics
38 * IntrinsicAvailableTest
39 * @run main/othervm -Xbootclasspath/a:.
40 * -XX:+UnlockDiagnosticVMOptions
41 * -XX:+WhiteBoxAPI
42 * -XX:-UseCRC32Intrinsics
43 * IntrinsicAvailableTest
44 */
45 public class IntrinsicAvailableTest extends CompilerWhiteBoxTest {
88
89 protected void checkIntrinsicForCompilationLevel(Executable method, int compLevel) throws Exception {
90 boolean intrinsicEnabled = Boolean.valueOf(getVMOption("UseCRC32Intrinsics"));
91 boolean intrinsicAvailable = WHITE_BOX.isIntrinsicAvailable(method,
92 compLevel);
93
94 String intrinsicEnabledMessage = intrinsicEnabled ? "enabled" : "disabled";
95 String intrinsicAvailableMessage = intrinsicAvailable ? "available" : "not available";
96
97 if (intrinsicEnabled == intrinsicAvailable) {
98 System.out.println("Expected result: intrinsic for java.util.zip.CRC32.update() is " +
99 intrinsicEnabledMessage + " and intrinsic is " + intrinsicAvailableMessage +
100 " at compilation level " + compLevel);
101 } else {
102 throw new RuntimeException("Unexpected result: intrinsic for java.util.zip.CRC32.update() is " +
103 intrinsicEnabledMessage + " but intrinsic is " + intrinsicAvailableMessage +
104 " at compilation level " + compLevel);
105 }
106 }
107
108 protected boolean isServerVM() {
109 return VMName.toLowerCase().contains("server");
110 }
111
112 public void test() throws Exception {
113 Executable intrinsicMethod = testCase.getExecutable();
114 if (isServerVM()) {
115 if (TIERED_COMPILATION) {
116 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
117 }
118 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION);
119 } else {
120 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
121 }
122 }
123
124 public static void main(String args[]) throws Exception {
125 new IntrinsicAvailableTest(new IntrinsicAvailableTestTestCase()).test();
126 }
127 }
|
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 import java.lang.reflect.Executable;
24 import java.util.concurrent.Callable;
25 import java.util.Objects;
26
27 import jdk.test.lib.*;
28 import compiler.whitebox.CompilerWhiteBoxTest;
29 /*
30 * @test
31 * @bug 8130832
32 * @library /testlibrary /test/lib /compiler/whitebox /compiler/testlibrary /
33 * @build IntrinsicAvailableTest
34 * @run main ClassFileInstaller sun.hotspot.WhiteBox
35 * sun.hotspot.WhiteBox$WhiteBoxPermission
36 * @run main/othervm -Xbootclasspath/a:.
37 * -XX:+UnlockDiagnosticVMOptions
38 * -XX:+WhiteBoxAPI
39 * -XX:+UseCRC32Intrinsics
40 * IntrinsicAvailableTest
41 * @run main/othervm -Xbootclasspath/a:.
42 * -XX:+UnlockDiagnosticVMOptions
43 * -XX:+WhiteBoxAPI
44 * -XX:-UseCRC32Intrinsics
45 * IntrinsicAvailableTest
46 */
47 public class IntrinsicAvailableTest extends CompilerWhiteBoxTest {
90
91 protected void checkIntrinsicForCompilationLevel(Executable method, int compLevel) throws Exception {
92 boolean intrinsicEnabled = Boolean.valueOf(getVMOption("UseCRC32Intrinsics"));
93 boolean intrinsicAvailable = WHITE_BOX.isIntrinsicAvailable(method,
94 compLevel);
95
96 String intrinsicEnabledMessage = intrinsicEnabled ? "enabled" : "disabled";
97 String intrinsicAvailableMessage = intrinsicAvailable ? "available" : "not available";
98
99 if (intrinsicEnabled == intrinsicAvailable) {
100 System.out.println("Expected result: intrinsic for java.util.zip.CRC32.update() is " +
101 intrinsicEnabledMessage + " and intrinsic is " + intrinsicAvailableMessage +
102 " at compilation level " + compLevel);
103 } else {
104 throw new RuntimeException("Unexpected result: intrinsic for java.util.zip.CRC32.update() is " +
105 intrinsicEnabledMessage + " but intrinsic is " + intrinsicAvailableMessage +
106 " at compilation level " + compLevel);
107 }
108 }
109
110 public void test() throws Exception {
111 Executable intrinsicMethod = testCase.getExecutable();
112 if (Platform.isServer()) {
113 if (TIERED_COMPILATION) {
114 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
115 }
116 // Dont bother check JVMCI compiler - returns false on all intrinsics.
117 if (!Boolean.valueOf(getVMOption("UseJVMCICompiler"))) {
118 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_FULL_OPTIMIZATION);
119 }
120 } else {
121 checkIntrinsicForCompilationLevel(intrinsicMethod, COMP_LEVEL_SIMPLE);
122 }
123 }
124
125 public static void main(String args[]) throws Exception {
126 new IntrinsicAvailableTest(new IntrinsicAvailableTestTestCase()).test();
127 }
128 }
|