1 /* 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test EnqueueMethodForCompilationTest 26 * @library /testlibrary /testlibrary/whitebox 27 * @build EnqueueMethodForCompilationTest 28 * @run main ClassFileInstaller sun.hotspot.WhiteBox 29 * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI EnqueueMethodForCompilationTest 30 * @author igor.ignatyev@oracle.com 31 */ 32 public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest { 33 public static void main(String[] args) throws Exception { 34 // to prevent inlining #method into #compile() 35 WHITE_BOX.setDontInlineMethod(METHOD, true); 36 new EnqueueMethodForCompilationTest().runTest(); 37 } 38 39 protected void test() throws Exception { 40 checkNotCompiled(METHOD); 41 42 WHITE_BOX.enqueueMethodForCompilation(METHOD, 0); 43 if (WHITE_BOX.isMethodCompilable(METHOD, 0)) { 44 throw new RuntimeException(METHOD + " is compiled at level"); 45 } 46 checkNotCompiled(METHOD); 47 48 WHITE_BOX.enqueueMethodForCompilation(METHOD, -1); 49 checkNotCompiled(METHOD); 50 51 WHITE_BOX.enqueueMethodForCompilation(METHOD, 5); 52 if (!WHITE_BOX.isMethodCompilable(METHOD, 5)) { 53 checkNotCompiled(METHOD); 54 compile(); 55 checkCompiled(METHOD); 56 } else { 57 checkCompiled(METHOD); 58 } 59 60 int compLevel = WHITE_BOX.getMethodCompilationLevel(METHOD); 61 WHITE_BOX.deoptimizeMethod(METHOD); 62 checkNotCompiled(METHOD); 63 64 WHITE_BOX.enqueueMethodForCompilation(METHOD, compLevel); 65 checkCompiled(METHOD); 66 WHITE_BOX.deoptimizeMethod(METHOD); 67 checkNotCompiled(METHOD); 68 69 compile(); 70 checkCompiled(METHOD); 71 WHITE_BOX.deoptimizeMethod(METHOD); 72 checkNotCompiled(METHOD); 73 } 74 }