iignatyev@4908: /* iignatyev@4908: * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. iignatyev@4908: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. iignatyev@4908: * iignatyev@4908: * This code is free software; you can redistribute it and/or modify it iignatyev@4908: * under the terms of the GNU General Public License version 2 only, as iignatyev@4908: * published by the Free Software Foundation. iignatyev@4908: * iignatyev@4908: * This code is distributed in the hope that it will be useful, but WITHOUT iignatyev@4908: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or iignatyev@4908: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License iignatyev@4908: * version 2 for more details (a copy is included in the LICENSE file that iignatyev@4908: * accompanied this code). iignatyev@4908: * iignatyev@4908: * You should have received a copy of the GNU General Public License version iignatyev@4908: * 2 along with this work; if not, write to the Free Software Foundation, iignatyev@4908: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. iignatyev@4908: * iignatyev@4908: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA iignatyev@4908: * or visit www.oracle.com if you need additional information or have any iignatyev@4908: * questions. iignatyev@4908: */ iignatyev@4908: iignatyev@4908: /* iignatyev@4908: * @test ClearMethodStateTest iignatyev@4908: * @library /testlibrary /testlibrary/whitebox iignatyev@4908: * @build ClearMethodStateTest iignatyev@4908: * @run main ClassFileInstaller sun.hotspot.WhiteBox iignatyev@4908: * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest iignatyev@4908: * @author igor.ignatyev@oracle.com iignatyev@4908: */ iignatyev@4908: public class ClearMethodStateTest extends CompilerWhiteBoxTest { iignatyev@4908: public static void main(String[] args) throws Exception { iignatyev@4908: // to prevent inlining #method into #compile() and #test() iignatyev@4908: WHITE_BOX.testSetDontInlineMethod(METHOD, true); iignatyev@4908: new ClearMethodStateTest().runTest(); iignatyev@4908: } iignatyev@4908: iignatyev@4908: protected void test() throws Exception { iignatyev@4908: checkNotCompiled(METHOD); iignatyev@4908: compile(); iignatyev@4908: checkCompiled(METHOD); iignatyev@4908: WHITE_BOX.clearMethodState(METHOD); iignatyev@4908: WHITE_BOX.deoptimizeMethod(METHOD); iignatyev@4908: checkNotCompiled(METHOD); iignatyev@4908: iignatyev@4908: iignatyev@4908: if (!TIERED_COMPILATION) { iignatyev@4908: WHITE_BOX.clearMethodState(METHOD); iignatyev@4908: compile(COMPILE_THRESHOLD); iignatyev@4908: checkCompiled(METHOD); iignatyev@4908: iignatyev@4908: WHITE_BOX.deoptimizeMethod(METHOD); iignatyev@4908: checkNotCompiled(METHOD); iignatyev@4908: WHITE_BOX.clearMethodState(METHOD); iignatyev@4908: iignatyev@4908: if (COMPILE_THRESHOLD > 1) { iignatyev@4908: compile(COMPILE_THRESHOLD - 1); iignatyev@4908: checkNotCompiled(METHOD); iignatyev@4908: } else { iignatyev@4908: System.err.println("Warning: 'CompileThreshold' <= 1"); iignatyev@4908: } iignatyev@4908: iignatyev@4908: method(); iignatyev@4908: checkCompiled(METHOD); iignatyev@4908: } else { iignatyev@4908: System.err.println( iignatyev@4908: "Warning: part of test is not applicable in Tiered"); iignatyev@4908: } iignatyev@4908: } iignatyev@4908: }