iignatyev@5982: /* iignatyev@6353: * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. iignatyev@5982: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. iignatyev@5982: * iignatyev@5982: * This code is free software; you can redistribute it and/or modify it iignatyev@5982: * under the terms of the GNU General Public License version 2 only, as iignatyev@5982: * published by the Free Software Foundation. iignatyev@5982: * iignatyev@5982: * This code is distributed in the hope that it will be useful, but WITHOUT iignatyev@5982: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or iignatyev@5982: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License iignatyev@5982: * version 2 for more details (a copy is included in the LICENSE file that iignatyev@5982: * accompanied this code). iignatyev@5982: * iignatyev@5982: * You should have received a copy of the GNU General Public License version iignatyev@5982: * 2 along with this work; if not, write to the Free Software Foundation, iignatyev@5982: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. iignatyev@5982: * iignatyev@5982: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA iignatyev@5982: * or visit www.oracle.com if you need additional information or have any iignatyev@5982: * questions. iignatyev@5982: */ iignatyev@5982: iignatyev@5982: /** iignatyev@5982: * @test TieredLevelsTest iignatyev@5982: * @library /testlibrary /testlibrary/whitebox /compiler/whitebox iignatyev@5982: * @build TieredLevelsTest iignatyev@5982: * @run main ClassFileInstaller sun.hotspot.WhiteBox iignatyev@5982: * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation iignatyev@5982: * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI iignatyev@6211: * -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* iignatyev@5982: * TieredLevelsTest iignatyev@5982: * @summary Verify that all levels < 'TieredStopAtLevel' can be used iignatyev@5982: * @author igor.ignatyev@oracle.com iignatyev@5982: */ iignatyev@5982: public class TieredLevelsTest extends CompLevelsTest { iignatyev@5982: public static void main(String[] args) throws Exception { iignatyev@5982: if (!TIERED_COMPILATION) { iignatyev@5982: System.err.println("Test isn't applicable w/ disabled " iignatyev@5982: + "TieredCompilation. Skip test."); iignatyev@5982: return; iignatyev@5982: } iignatyev@6211: CompilerWhiteBoxTest.main(TieredLevelsTest::new, args); iignatyev@5982: } iignatyev@5982: iignatyev@5982: private TieredLevelsTest(TestCase testCase) { iignatyev@5982: super(testCase); iignatyev@5982: // to prevent inlining of #method iignatyev@5982: WHITE_BOX.testSetDontInlineMethod(method, true); iignatyev@5982: } iignatyev@5982: iignatyev@5982: @Override iignatyev@5982: protected void test() throws Exception { iignatyev@6353: if (skipXcompOSR()) { iignatyev@6353: return; iignatyev@6353: } iignatyev@5982: checkNotCompiled(); iignatyev@5982: compile(); iignatyev@5982: checkCompiled(); iignatyev@5982: iignatyev@5982: int compLevel = getCompLevel(); iignatyev@5982: if (compLevel > TIERED_STOP_AT_LEVEL) { iignatyev@5982: throw new RuntimeException("method.compLevel[" + compLevel iignatyev@5982: + "] > TieredStopAtLevel [" + TIERED_STOP_AT_LEVEL + "]"); iignatyev@5982: } iignatyev@5982: int bci = WHITE_BOX.getMethodEntryBci(method); iignatyev@5982: deoptimize(); iignatyev@5982: iignatyev@5982: for (int testedTier = 1; testedTier <= TIERED_STOP_AT_LEVEL; iignatyev@5982: ++testedTier) { iignatyev@5982: testAvailableLevel(testedTier, bci); iignatyev@5982: } iignatyev@5982: for (int testedTier = TIERED_STOP_AT_LEVEL + 1; iignatyev@5982: testedTier <= COMP_LEVEL_MAX; ++testedTier) { iignatyev@5982: testUnavailableLevel(testedTier, bci); iignatyev@5982: } iignatyev@5982: } iignatyev@5982: iignatyev@5982: iignatyev@5982: @Override iignatyev@5982: protected void checkLevel(int expected, int actual) { iignatyev@5982: if (expected == COMP_LEVEL_FULL_PROFILE iignatyev@5982: && actual == COMP_LEVEL_LIMITED_PROFILE) { iignatyev@5982: // for simple method full_profile may be replaced by limited_profile iignatyev@5982: return; iignatyev@5982: } iignatyev@5982: super.checkLevel(expected, actual); iignatyev@5982: } iignatyev@5982: }