< prev index next >

test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java

Print this page
rev 59076 : [mq]: 8243945


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @bug 8226956
  28  * @requires vm.jvmci
  29  * @summary Run invocation tests against Graal compiler
  30  * @library /test/lib
  31  * @modules java.base/jdk.internal.org.objectweb.asm
  32  *          java.base/jdk.internal.misc
  33  * @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java
  34  *          shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java
  35  *          shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java
  36  * @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java
  37  *          invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
  38  *          invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java
  39  *
  40  * @run main/othervm/timeout=1800 invocationGraalTests
  41  */
  42 
  43 import jdk.test.lib.process.ProcessTools;
  44 import jdk.test.lib.process.OutputAnalyzer;
  45 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  46 
  47 public class invocationGraalTests {
  48 
  49     public static void runTest(String whichTests, String classFileVersion) throws Exception {
  50         System.out.println("\nGraal invocation tests, Tests: " + whichTests +
  51                            ", class file version: " + classFileVersion);
  52         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M",
  53             "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler",
  54             "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
  55             whichTests, "--classfile_version=" + classFileVersion);
  56         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  57         try {
  58             output.shouldContain("EXECUTION STATUS: PASSED");
  59             output.shouldHaveExitValue(0);
  60         } catch (Throwable e) {
  61             System.out.println(
  62                 "\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +
  63                 " the test case failed because method B.m was invoked but the test " +
  64                 "expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +
  65                 " means that an AbstractMethodError exception was thrown but the test" +
  66                 " case expected method C.m to be invoked.");
  67             System.out.println(
  68                 "\nAlso note that passing --dump to invoke*.Generator will" +
  69                 " dump the generated classes (for debugging purposes).\n");
  70             System.exit(1);

  71         }
  72     }
  73 
  74     public static void main(String args[]) throws Throwable {
  75         // Get current major class file version and test with it.
  76         byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
  77         int major_version = klassbuf[6] << 8 | klassbuf[7];
  78         runTest("invokevirtual.Generator", String.valueOf(major_version));
  79         runTest("invokespecial.Generator", String.valueOf(major_version));
  80         runTest("invokeinterface.Generator", String.valueOf(major_version));
  81     }
  82 }


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @bug 8226956
  28  * @requires vm.jvmci
  29  * @summary Run invocation tests against Graal compiler
  30  * @library /test/lib
  31  * @modules java.base/jdk.internal.org.objectweb.asm
  32  *          java.base/jdk.internal.misc
  33  * @compile shared/AbstractGenerator.java shared/AccessCheck.java shared/AccessType.java
  34  *          shared/Caller.java shared/ExecutorGenerator.java shared/Utils.java
  35  *          shared/ByteArrayClassLoader.java shared/Checker.java shared/GenericClassGenerator.java
  36  * @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java
  37  *          invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java
  38  *          invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java
  39  *
  40  * @run driver/timeout=1800 invocationGraalTests
  41  */
  42 
  43 import jdk.test.lib.process.ProcessTools;
  44 import jdk.test.lib.process.OutputAnalyzer;
  45 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  46 
  47 public class invocationGraalTests {
  48 
  49     public static void runTest(String whichTests, String classFileVersion) throws Throwable {
  50         System.out.println("\nGraal invocation tests, Tests: " + whichTests +
  51                            ", class file version: " + classFileVersion);
  52         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M",
  53             "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler",
  54             "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",
  55             whichTests, "--classfile_version=" + classFileVersion);
  56         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  57         try {
  58             output.shouldContain("EXECUTION STATUS: PASSED");
  59             output.shouldHaveExitValue(0);
  60         } catch (Throwable e) {
  61             System.out.println(
  62                 "\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +
  63                 " the test case failed because method B.m was invoked but the test " +
  64                 "expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +
  65                 " means that an AbstractMethodError exception was thrown but the test" +
  66                 " case expected method C.m to be invoked.");
  67             System.out.println(
  68                 "\nAlso note that passing --dump to invoke*.Generator will" +
  69                 " dump the generated classes (for debugging purposes).\n");
  70 
  71             throw e;
  72         }
  73     }
  74 
  75     public static void main(String args[]) throws Throwable {
  76         // Get current major class file version and test with it.
  77         byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");
  78         int major_version = klassbuf[6] << 8 | klassbuf[7];
  79         runTest("invokevirtual.Generator", String.valueOf(major_version));
  80         runTest("invokespecial.Generator", String.valueOf(major_version));
  81         runTest("invokeinterface.Generator", String.valueOf(major_version));
  82     }
  83 }
< prev index next >