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 // TODO add bugid and summary
25
26 /*
27 * @test
28 * @library /testlibrary /test/lib /compiler/whitebox /
29 * @build compiler.valhalla.valuetypes.ValueTypeTestBench
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * @run main ClassFileInstaller jdk.test.lib.Platform
32 * @run main/othervm -ea -noverify -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
33 * -XX:-TieredCompilation compiler.valhalla.valuetypes.ValueTypeTestBench
34 * @run main/othervm -ea -noverify -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
35 * -XX:+UnlockExperimentalVMOptions -XX:-ValueTypePassFieldsAsArgs
36 * -XX:-TieredCompilation compiler.valhalla.valuetypes.ValueTypeTestBench
37 */
38
39 package compiler.valhalla.valuetypes;
40
41 import compiler.whitebox.CompilerWhiteBoxTest;
42 import jdk.internal.misc.Unsafe;
43 import jdk.test.lib.Asserts;
44 import jdk.test.lib.Platform;
45 import jdk.test.lib.ProcessTools;
46 import jdk.test.lib.OutputAnalyzer;
47 import jdk.test.lib.Utils;
48 import sun.hotspot.WhiteBox;
49
50 import java.lang.annotation.Retention;
51 import java.lang.annotation.RetentionPolicy;
52 import java.lang.annotation.Repeatable;
796 private static final String MID = ".*)+\\t===.*";
797 private static final String END = ")|";
798 private static final String ALLOC = START + "CallStaticJava" + MID + "_new_instance_Java" + END;
799 private static final String LOAD = START + "Load" + MID + "valuetype\\*" + END;
800 private static final String STORE = START + "Store" + MID + "valuetype\\*" + END;
801 private static final String LOOP = START + "Loop" + MID + "" + END;
802 private static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap" + END;
803 // TODO: match field values of scalar replaced object
804 private static final String SCOBJ = "(.*# ScObj.*" + END;
805
806 static {
807 // Gather all test methods and put them in Hashtable
808 for (Method m : ValueTypeTestBench.class.getDeclaredMethods()) {
809 Test[] annos = m.getAnnotationsByType(Test.class);
810 if (annos.length != 0) {
811 tests.put("ValueTypeTestBench::" + m.getName(), m);
812 }
813 }
814 }
815
816 public static void main(String[] args) throws Throwable {
817 if (args.length == 0) {
818 ArrayList<String> all_args = new ArrayList(List.of(
819 "-noverify",
820 "-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI",
821 "-XX:-TieredCompilation", "-XX:-BackgroundCompilation",
822 "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
823 "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*",
824 "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue1::*",
825 "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue2::*"
826 ));
827 // Run tests in own process and verify output
828 all_args.add("-XX:+UnlockExperimentalVMOptions");
829 if ((Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs")) {
830 all_args.add("-XX:+ValueTypePassFieldsAsArgs");
831 } else {
832 all_args.add("-XX:-ValueTypePassFieldsAsArgs");
833 }
834 all_args.add(ValueTypeTestBench.class.getName());
835 all_args.add("run");
836 OutputAnalyzer oa = ProcessTools.executeTestJvm(all_args.toArray(new String[0]));
837 // If ideal graph printing is enabled/supported, verify output
838 String output = oa.getOutput();
839 oa.shouldHaveExitValue(0);
840 if (output.contains("PrintIdeal enabled")) {
841 parseOutput(output);
842 } else {
843 System.out.println("WARNING: IR verification disabled! Running with -Xint, -Xcomp or release build?");
844 }
845 } else {
846 if (USE_COMPILER && PRINT_IDEAL && !XCOMP) {
847 System.out.println("PrintIdeal enabled");
848 }
849 // Execute tests
850 ValueTypeTestBench bench = new ValueTypeTestBench();
851 bench.run();
852 }
853 }
854
855 public static void parseOutput(String output) throws Exception {
856 String split = "b compiler.valhalla.valuetypes.";
857 String[] compilations = output.split(split);
858 // Print header
859 System.out.println(compilations[0]);
860 // Iterate over compilation output
861 for (String graph : compilations) {
862 String[] lines = graph.split("\\n");
863 if (lines[0].contains("@")) {
864 continue; // Ignore OSR compilations
|
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 // TODO add bugid and summary
25
26 /*
27 * @test
28 * @library /testlibrary /test/lib /compiler/whitebox /
29 * @build compiler.valhalla.valuetypes.ValueTypeTestBench
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox
31 * @run main ClassFileInstaller jdk.test.lib.Platform
32 * @run main/othervm -ea -noverify -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
33 * -XX:+UnlockExperimentalVMOptions -XX:+ValueTypePassFieldsAsArgs
34 * -XX:-TieredCompilation compiler.valhalla.valuetypes.ValueTypeTestBench
35 * @run main/othervm -ea -noverify -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
36 * -XX:+UnlockExperimentalVMOptions -XX:-ValueTypePassFieldsAsArgs
37 * -XX:-TieredCompilation compiler.valhalla.valuetypes.ValueTypeTestBench
38 */
39
40 package compiler.valhalla.valuetypes;
41
42 import compiler.whitebox.CompilerWhiteBoxTest;
43 import jdk.internal.misc.Unsafe;
44 import jdk.test.lib.Asserts;
45 import jdk.test.lib.Platform;
46 import jdk.test.lib.ProcessTools;
47 import jdk.test.lib.OutputAnalyzer;
48 import jdk.test.lib.Utils;
49 import sun.hotspot.WhiteBox;
50
51 import java.lang.annotation.Retention;
52 import java.lang.annotation.RetentionPolicy;
53 import java.lang.annotation.Repeatable;
797 private static final String MID = ".*)+\\t===.*";
798 private static final String END = ")|";
799 private static final String ALLOC = START + "CallStaticJava" + MID + "_new_instance_Java" + END;
800 private static final String LOAD = START + "Load" + MID + "valuetype\\*" + END;
801 private static final String STORE = START + "Store" + MID + "valuetype\\*" + END;
802 private static final String LOOP = START + "Loop" + MID + "" + END;
803 private static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap" + END;
804 // TODO: match field values of scalar replaced object
805 private static final String SCOBJ = "(.*# ScObj.*" + END;
806
807 static {
808 // Gather all test methods and put them in Hashtable
809 for (Method m : ValueTypeTestBench.class.getDeclaredMethods()) {
810 Test[] annos = m.getAnnotationsByType(Test.class);
811 if (annos.length != 0) {
812 tests.put("ValueTypeTestBench::" + m.getName(), m);
813 }
814 }
815 }
816
817 private static void execute_vm(String... extra_args) throws Throwable {
818 ArrayList<String> all_args = new ArrayList(List.of(
819 "-noverify",
820 "-XX:+UnlockDiagnosticVMOptions", "-Xbootclasspath/a:.", "-XX:+WhiteBoxAPI",
821 "-XX:-TieredCompilation", "-XX:-BackgroundCompilation",
822 "-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
823 "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*",
824 "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue1::*",
825 "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.MyValue2::*"
826 ));
827 all_args.addAll(List.of(extra_args));
828 // Run tests in own process and verify output
829 all_args.add(ValueTypeTestBench.class.getName());
830 all_args.add("run");
831 OutputAnalyzer oa = ProcessTools.executeTestJvm(all_args.toArray(new String[0]));
832 // If ideal graph printing is enabled/supported, verify output
833 String output = oa.getOutput();
834 oa.shouldHaveExitValue(0);
835 if (output.contains("PrintIdeal enabled")) {
836 parseOutput(output);
837 } else {
838 System.out.println("WARNING: IR verification disabled! Running with -Xint, -Xcomp or release build?");
839 }
840 }
841
842 public static void main(String[] args) throws Throwable {
843 if (args.length == 0) {
844 String field_as_args;
845 if ((Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs")) {
846 field_as_args = "-XX:+ValueTypePassFieldsAsArgs";
847 } else {
848 field_as_args = "-XX:-ValueTypePassFieldsAsArgs";
849 }
850 execute_vm("-XX:+UnlockExperimentalVMOptions", field_as_args);
851 execute_vm("-XX:+AlwaysIncrementalInline", "-XX:+UnlockExperimentalVMOptions", field_as_args);
852 } else {
853 if (USE_COMPILER && PRINT_IDEAL && !XCOMP) {
854 System.out.println("PrintIdeal enabled");
855 }
856 // Execute tests
857 ValueTypeTestBench bench = new ValueTypeTestBench();
858 bench.run();
859 }
860 }
861
862 public static void parseOutput(String output) throws Exception {
863 String split = "b compiler.valhalla.valuetypes.";
864 String[] compilations = output.split(split);
865 // Print header
866 System.out.println(compilations[0]);
867 // Iterate over compilation output
868 for (String graph : compilations) {
869 String[] lines = graph.split("\\n");
870 if (lines[0].contains("@")) {
871 continue; // Ignore OSR compilations
|