Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.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/lib28* ../common/patches29* @modules java.base/jdk.internal.misc30* jdk.internal.vm.ci/jdk.vm.ci.hotspot31*32* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper33* sun.hotspot.WhiteBox34* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox35* @run main/othervm -Xbootclasspath/a:.36* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI37* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI38* compiler.jvmci.compilerToVM.IsMatureTest39*/4041package compiler.jvmci.compilerToVM;4243import compiler.jvmci.common.testcases.SimpleClass;44import compiler.whitebox.CompilerWhiteBoxTest;45import jdk.test.lib.Asserts;46import jdk.test.lib.Platform;47import jdk.vm.ci.hotspot.CompilerToVMHelper;48import sun.hotspot.WhiteBox;4950import java.lang.reflect.Executable;5152public class IsMatureTest {53private static final WhiteBox WB = WhiteBox.getWhiteBox();54private static final boolean TIERED55= WB.getBooleanVMFlag("TieredCompilation");5657public static void main(String[] args) throws Exception {58new IsMatureTest().test();59}6061public void test() throws Exception {62SimpleClass sclass = new SimpleClass();63Executable method = SimpleClass.class.getDeclaredMethod("testMethod");64long methodData = WB.getMethodData(method);65boolean isMature = CompilerToVMHelper.isMature(methodData);66Asserts.assertEQ(methodData, 0L,67"Never invoked method can't have method data");68Asserts.assertFalse(isMature, "Never invoked method can't be mature");69for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {70sclass.testMethod();71}72methodData = WB.getMethodData(method);73isMature = CompilerToVMHelper.isMature(methodData);74int compLevel = WB.getMethodCompilationLevel(method);75// methodData doesn't necessarily exist for interpreter and compilation level 176if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_NONE77&& compLevel != CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE) {78Asserts.assertNE(methodData, 0L,79"Multiple times invoked method should have method data");80/* a method is not mature in Xcomp mode with tiered compilation disabled,81see NonTieredCompPolicy::is_mature */82Asserts.assertEQ(isMature, !(Platform.isComp() && !TIERED),83"Unexpected isMature state for multiple times invoked method");84}85}86}878889