1 /*
2 * Copyright (c) 2013, 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 import com.oracle.java.testlibrary.Platform;
25
26 import java.io.FileOutputStream;
27 import java.lang.reflect.Executable;
28 import java.util.Properties;
29
30 public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
31 protected String javaVmName;
32 protected String useMathExactIntrinsics;
33
34 protected IntrinsicBase(TestCase testCase) {
35 super(testCase);
36 javaVmName = System.getProperty("java.vm.name");
37 useMathExactIntrinsics = getVMOption("UseMathExactIntrinsics");
38 }
39
40 @Override
41 protected void test() throws Exception {
42 //java.lang.Math should be loaded to allow a compilation of the methods that use Math's method
43 System.out.println("class java.lang.Math should be loaded. Proof: " + Math.class);
44 printEnvironmentInfo();
62 compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
63 }
64 } else {
65 deoptimize();
66 compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
67 }
68
69 if (!isIntrinsicSupported()) {
70 expectedIntrinsicCount = 0;
71 }
72 break;
73 case "interpreted mode": //test is not applicable in this mode;
74 System.err.println("Warning: This test is not applicable in mode: " + MODE);
75 break;
76 default:
77 throw new RuntimeException("Test bug, unknown VM mode: " + MODE);
78 }
79
80 System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId());
81
82 final FileOutputStream out = new FileOutputStream(getVMOption("LogFile") + ".verify.properties");
83 Properties expectedProps = new Properties();
84 expectedProps.setProperty("intrinsic.name", getIntrinsicId());
85 expectedProps.setProperty("intrinsic.expectedCount", String.valueOf(expectedIntrinsicCount));
86 expectedProps.store(out, null);
87
88 out.close();
89 }
90
91 protected void printEnvironmentInfo() {
92 System.out.println("java.vm.name=" + javaVmName);
93 System.out.println("os.arch=" + Platform.getOsArch());
94 System.out.println("java.vm.info=" + MODE);
95 System.out.println("useMathExactIntrinsics=" + useMathExactIntrinsics);
96 }
97
98 protected void compileAtLevel(int level) {
99 WHITE_BOX.enqueueMethodForCompilation(method, level);
100 waitBackgroundCompilation();
101 checkCompilation(method, level);
102 }
103
104 protected void checkCompilation(Executable executable, int level) {
105 if (!WHITE_BOX.isMethodCompiled(executable)) {
|
1 /*
2 * Copyright (c) 2013, 2014, 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 import com.oracle.java.testlibrary.Platform;
25 import intrinsics.Verifier;
26
27 import java.io.FileOutputStream;
28 import java.lang.reflect.Executable;
29 import java.util.Properties;
30
31 public abstract class IntrinsicBase extends CompilerWhiteBoxTest {
32 protected String javaVmName;
33 protected String useMathExactIntrinsics;
34
35 protected IntrinsicBase(TestCase testCase) {
36 super(testCase);
37 javaVmName = System.getProperty("java.vm.name");
38 useMathExactIntrinsics = getVMOption("UseMathExactIntrinsics");
39 }
40
41 @Override
42 protected void test() throws Exception {
43 //java.lang.Math should be loaded to allow a compilation of the methods that use Math's method
44 System.out.println("class java.lang.Math should be loaded. Proof: " + Math.class);
45 printEnvironmentInfo();
63 compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
64 }
65 } else {
66 deoptimize();
67 compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
68 }
69
70 if (!isIntrinsicSupported()) {
71 expectedIntrinsicCount = 0;
72 }
73 break;
74 case "interpreted mode": //test is not applicable in this mode;
75 System.err.println("Warning: This test is not applicable in mode: " + MODE);
76 break;
77 default:
78 throw new RuntimeException("Test bug, unknown VM mode: " + MODE);
79 }
80
81 System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId());
82
83 final FileOutputStream out = new FileOutputStream(getVMOption("LogFile") + Verifier.PROPERTY_FILE_SUFFIX);
84 Properties expectedProps = new Properties();
85 expectedProps.setProperty(Verifier.INTRINSIC_NAME_PROPERTY, getIntrinsicId());
86 expectedProps.setProperty(Verifier.INTRINSIC_EXPECTED_COUNT_PROPERTY, String.valueOf(expectedIntrinsicCount));
87 expectedProps.store(out, null);
88
89 out.close();
90 }
91
92 protected void printEnvironmentInfo() {
93 System.out.println("java.vm.name=" + javaVmName);
94 System.out.println("os.arch=" + Platform.getOsArch());
95 System.out.println("java.vm.info=" + MODE);
96 System.out.println("useMathExactIntrinsics=" + useMathExactIntrinsics);
97 }
98
99 protected void compileAtLevel(int level) {
100 WHITE_BOX.enqueueMethodForCompilation(method, level);
101 waitBackgroundCompilation();
102 checkCompilation(method, level);
103 }
104
105 protected void checkCompilation(Executable executable, int level) {
106 if (!WHITE_BOX.isMethodCompiled(executable)) {
|