Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/HasNeverInlineDirectiveTest.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.jvmci27* @library /test/lib /28* @library ../common/patches29* @modules java.base/jdk.internal.misc30* @modules java.base/jdk.internal.org.objectweb.asm31* java.base/jdk.internal.org.objectweb.asm.tree32* jdk.internal.vm.ci/jdk.vm.ci.hotspot33* jdk.internal.vm.ci/jdk.vm.ci.code34* jdk.internal.vm.ci/jdk.vm.ci.meta35* jdk.internal.vm.ci/jdk.vm.ci.runtime36*37* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox38* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox39* @run main/othervm -Xbootclasspath/a:.40* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI41* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI42* -XX:-UseJVMCICompiler43* compiler.jvmci.compilerToVM.HasNeverInlineDirectiveTest44*/4546package compiler.jvmci.compilerToVM;4748import compiler.jvmci.common.CTVMUtilities;49import jdk.test.lib.Asserts;50import jdk.vm.ci.hotspot.CompilerToVMHelper;51import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;52import sun.hotspot.WhiteBox;5354import java.lang.reflect.Executable;55import java.util.ArrayList;56import java.util.Arrays;57import java.util.List;5859public class HasNeverInlineDirectiveTest {6061private static final WhiteBox WB = WhiteBox.getWhiteBox();6263public static void main(String[] args) {64List<Executable> testCases = createTestCases();65testCases.forEach(HasNeverInlineDirectiveTest::runSanityTest);66}6768private static void runSanityTest(Executable aMethod) {69HotSpotResolvedJavaMethod method = CTVMUtilities70.getResolvedMethod(aMethod);71boolean hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method);72boolean expected = WB.testSetDontInlineMethod(aMethod, true);73Asserts.assertEQ(hasNeverInlineDirective, expected, "Unexpected initial " +74"value of property 'hasNeverInlineDirective'");7576hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method);77Asserts.assertTrue(hasNeverInlineDirective, aMethod + "Unexpected value of " +78"property 'hasNeverInlineDirective' after setting 'do not inline' to true");79WB.testSetDontInlineMethod(aMethod, false);80hasNeverInlineDirective = CompilerToVMHelper.hasNeverInlineDirective(method);81Asserts.assertFalse(hasNeverInlineDirective, "Unexpected value of " +82"property 'hasNeverInlineDirective' after setting 'do not inline' to false");83}8485private static List<Executable> createTestCases() {86List<Executable> testCases = new ArrayList<>();8788Class<?> aClass = DummyClass.class;89testCases.addAll(Arrays.asList(aClass.getDeclaredMethods()));90testCases.addAll(Arrays.asList(aClass.getDeclaredConstructors()));91return testCases;92}93}949596