Path: blob/master/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java
64492 views
/*1* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/*25* @test id=special26* @bug 822695627* @summary Run invocation tests against C1 compiler28* @library /test/lib29* @modules java.base/jdk.internal.org.objectweb.asm30* java.base/jdk.internal.misc31* @compile invokespecial/Checker.java invokespecial/ClassGenerator.java invokespecial/Generator.java32*33* @run driver/timeout=1800 invocationC1Tests special34*/3536/*37* @test id=virtual38* @bug 822695639* @summary Run invocation tests against C1 compiler40* @requires vm.flagless41* @library /test/lib42* @modules java.base/jdk.internal.org.objectweb.asm43* java.base/jdk.internal.misc44* @compile invokevirtual/Checker.java invokevirtual/ClassGenerator.java invokevirtual/Generator.java45*46* @run driver/timeout=1800 invocationC1Tests virtual47*/4849/*50* @test id=interface51* @bug 822695652* @summary Run invocation tests against C1 compiler53* @requires vm.flagless54* @library /test/lib55* @modules java.base/jdk.internal.org.objectweb.asm56* java.base/jdk.internal.misc57* @compile invokeinterface/Checker.java invokeinterface/ClassGenerator.java invokeinterface/Generator.java58*59* @run driver/timeout=1800 invocationC1Tests interface60*/6162import jdk.test.lib.process.ProcessTools;63import jdk.test.lib.process.OutputAnalyzer;64import jdk.test.lib.compiler.InMemoryJavaCompiler;6566public class invocationC1Tests {6768public static void runTest(String whichTests, String classFileVersion) throws Throwable {69System.out.println("\nC1 invocation tests, Tests: " + whichTests +70", class file version: " + classFileVersion);71ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M",72"-Xcomp", "-XX:TieredStopAtLevel=1",73"--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED",74whichTests, "--classfile_version=" + classFileVersion);75OutputAnalyzer output = new OutputAnalyzer(pb.start());76try {77output.shouldContain("EXECUTION STATUS: PASSED");78output.shouldHaveExitValue(0);79} catch (Throwable e) {80System.out.println(81"\nNote that an entry such as 'B.m/C.m' in the failure chart means that" +82" the test case failed because method B.m was invoked but the test " +83"expected method C.m to be invoked. Similarly, a result such as 'AME/C.m'" +84" means that an AbstractMethodError exception was thrown but the test" +85" case expected method C.m to be invoked.");86System.out.println(87"\nAlso note that passing --dump to invoke*.Generator will" +88" dump the generated classes (for debugging purposes).\n");8990throw e;91}92}9394public static void main(String args[]) throws Throwable {95if (args.length < 1) {96throw new IllegalArgumentException("Should provide the test name");97}98String testName = args[0];99100// Get current major class file version and test with it.101byte klassbuf[] = InMemoryJavaCompiler.compile("blah", "public class blah { }");102int major_version = klassbuf[6] << 8 | klassbuf[7];103104switch (testName) {105case "special":106runTest("invokespecial.Generator", String.valueOf(major_version));107break;108case "virtual":109runTest("invokevirtual.Generator", String.valueOf(major_version));110break;111case "interface":112runTest("invokeinterface.Generator", String.valueOf(major_version));113break;114default:115throw new IllegalArgumentException("Unknown test name: " + testName);116}117}118}119120121