Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsCompilableTest.java
41153 views
/*1* Copyright (c) 2015, 2021, 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*/2223/**24* @test25* @bug 813642126* @requires vm.graal.enabled & vm.compMode == "Xmixed"27* @library /test/lib /28* @library ../common/patches29* @modules jdk.internal.vm.compiler30* @modules java.base/jdk.internal.misc31* @modules java.base/jdk.internal.org.objectweb.asm32* java.base/jdk.internal.org.objectweb.asm.tree33* jdk.internal.vm.ci/jdk.vm.ci.hotspot34* jdk.internal.vm.ci/jdk.vm.ci.code35* jdk.internal.vm.ci/jdk.vm.ci.meta36* jdk.internal.vm.ci/jdk.vm.ci.runtime37*38* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox39* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox40* @run main/othervm -Xbootclasspath/a:.41* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI42* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler43* compiler.jvmci.compilerToVM.IsCompilableTest44*/4546/**47* @test48* @requires vm.jvmci & vm.compMode == "Xmixed"49* @library /test/lib /50* @library ../common/patches51* @modules java.base/jdk.internal.misc52* @modules java.base/jdk.internal.org.objectweb.asm53* java.base/jdk.internal.org.objectweb.asm.tree54* jdk.internal.vm.ci/jdk.vm.ci.hotspot55* jdk.internal.vm.ci/jdk.vm.ci.code56* jdk.internal.vm.ci/jdk.vm.ci.meta57* jdk.internal.vm.ci/jdk.vm.ci.runtime58*59* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox60* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox61* @run main/othervm -Xbootclasspath/a:.62* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI63* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler64* compiler.jvmci.compilerToVM.IsCompilableTest65*/6667package compiler.jvmci.compilerToVM;6869import compiler.jvmci.common.CTVMUtilities;70import jdk.test.lib.Asserts;71import jdk.vm.ci.hotspot.CompilerToVMHelper;72import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;73import sun.hotspot.WhiteBox;7475import java.lang.reflect.Executable;76import java.util.ArrayList;77import java.util.Arrays;78import java.util.List;7980public class IsCompilableTest {8182private static final WhiteBox WB = WhiteBox.getWhiteBox();8384public static void main(String[] args) {85List<Executable> testCases = createTestCases();86testCases.forEach(IsCompilableTest::runSanityTest);87}8889private static void runSanityTest(Executable aMethod) {90HotSpotResolvedJavaMethod method = CTVMUtilities91.getResolvedMethod(aMethod);92boolean isCompilable = CompilerToVMHelper.isCompilable(method);93boolean expected = WB.isMethodCompilable(aMethod);94Asserts.assertEQ(isCompilable, expected, "Unexpected initial " +95"value of property 'compilable'");9697WB.makeMethodNotCompilable(aMethod);98isCompilable = CompilerToVMHelper.isCompilable(method);99Asserts.assertFalse(isCompilable, aMethod + "Unexpected value of " +100"property 'isCompilable' after setting 'compilable' to false");101}102103private static List<Executable> createTestCases() {104List<Executable> testCases = new ArrayList<>();105106Class<?> aClass = DummyClass.class;107testCases.addAll(Arrays.asList(aClass.getDeclaredMethods()));108testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors()));109return testCases;110}111}112113114