Sat, 28 Sep 2013 12:32:10 +0400
8023452: TestCase$Helper(java.lang.Object) must be osr_compiled
Reviewed-by: kvn
iignatyev@4592 | 1 | /* |
iignatyev@4592 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
iignatyev@4592 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
iignatyev@4592 | 4 | * |
iignatyev@4592 | 5 | * This code is free software; you can redistribute it and/or modify it |
iignatyev@4592 | 6 | * under the terms of the GNU General Public License version 2 only, as |
iignatyev@4592 | 7 | * published by the Free Software Foundation. |
iignatyev@4592 | 8 | * |
iignatyev@4592 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
iignatyev@4592 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
iignatyev@4592 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
iignatyev@4592 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
iignatyev@4592 | 13 | * accompanied this code). |
iignatyev@4592 | 14 | * |
iignatyev@4592 | 15 | * You should have received a copy of the GNU General Public License version |
iignatyev@4592 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
iignatyev@4592 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
iignatyev@4592 | 18 | * |
iignatyev@4592 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
iignatyev@4592 | 20 | * or visit www.oracle.com if you need additional information or have any |
iignatyev@4592 | 21 | * questions. |
iignatyev@4592 | 22 | */ |
iignatyev@4592 | 23 | |
iignatyev@4592 | 24 | /* |
iignatyev@4592 | 25 | * @test IsMethodCompilableTest |
iignatyev@5541 | 26 | * @bug 8007270 8006683 8007288 8022832 |
mgerdin@4637 | 27 | * @library /testlibrary /testlibrary/whitebox |
mgerdin@4637 | 28 | * @build IsMethodCompilableTest |
mgerdin@4637 | 29 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
iignatyev@5541 | 30 | * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* IsMethodCompilableTest |
iignatyev@4951 | 31 | * @summary testing of WB::isMethodCompilable() |
iignatyev@4592 | 32 | * @author igor.ignatyev@oracle.com |
iignatyev@4592 | 33 | */ |
iignatyev@4592 | 34 | public class IsMethodCompilableTest extends CompilerWhiteBoxTest { |
iignatyev@4951 | 35 | /** |
iignatyev@4951 | 36 | * Value of {@code -XX:PerMethodRecompilationCutoff} |
iignatyev@4951 | 37 | */ |
iignatyev@4592 | 38 | protected static final long PER_METHOD_RECOMPILATION_CUTOFF; |
iignatyev@4592 | 39 | |
iignatyev@4592 | 40 | static { |
iignatyev@4592 | 41 | long tmp = Long.parseLong( |
iignatyev@4592 | 42 | getVMOption("PerMethodRecompilationCutoff", "400")); |
iignatyev@4592 | 43 | if (tmp == -1) { |
iignatyev@4592 | 44 | PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; |
iignatyev@4592 | 45 | } else { |
iignatyev@4592 | 46 | PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp); |
iignatyev@4592 | 47 | } |
iignatyev@4592 | 48 | } |
iignatyev@4592 | 49 | |
iignatyev@4592 | 50 | public static void main(String[] args) throws Exception { |
iignatyev@4951 | 51 | for (TestCase test : TestCase.values()) { |
iignatyev@4951 | 52 | new IsMethodCompilableTest(test).runTest(); |
iignatyev@4951 | 53 | } |
iignatyev@4592 | 54 | } |
iignatyev@4592 | 55 | |
iignatyev@4951 | 56 | public IsMethodCompilableTest(TestCase testCase) { |
iignatyev@4951 | 57 | super(testCase); |
iignatyev@4951 | 58 | // to prevent inlining of #method |
iignatyev@4951 | 59 | WHITE_BOX.testSetDontInlineMethod(method, true); |
iignatyev@4951 | 60 | } |
iignatyev@4951 | 61 | |
iignatyev@4951 | 62 | /** |
iignatyev@4951 | 63 | * Tests {@code WB::isMethodCompilable()} by recompilation of tested method |
iignatyev@4951 | 64 | * 'PerMethodRecompilationCutoff' times and checks compilation status. Also |
iignatyev@4951 | 65 | * checks that WB::clearMethodState() clears no-compilable flags. |
iignatyev@4951 | 66 | * |
iignatyev@4951 | 67 | * @throws Exception if one of the checks fails. |
iignatyev@4951 | 68 | */ |
iignatyev@4951 | 69 | @Override |
iignatyev@4592 | 70 | protected void test() throws Exception { |
iignatyev@5796 | 71 | if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( |
iignatyev@5796 | 72 | "compiled ")) { |
iignatyev@5796 | 73 | System.err.printf("Warning: %s is not applicable in %s%n", |
iignatyev@5796 | 74 | testCase.name(), CompilerWhiteBoxTest.MODE); |
iignatyev@5796 | 75 | return; |
iignatyev@5796 | 76 | } |
iignatyev@5541 | 77 | if (!isCompilable()) { |
iignatyev@4951 | 78 | throw new RuntimeException(method + " must be compilable"); |
iignatyev@4592 | 79 | } |
iignatyev@4592 | 80 | System.out.println("PerMethodRecompilationCutoff = " |
iignatyev@4592 | 81 | + PER_METHOD_RECOMPILATION_CUTOFF); |
iignatyev@4592 | 82 | if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
iignatyev@4592 | 83 | System.err.println( |
iignatyev@4592 | 84 | "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
iignatyev@4592 | 85 | return; |
iignatyev@4592 | 86 | } |
iignatyev@4592 | 87 | |
iignatyev@4951 | 88 | // deoptimize 'PerMethodRecompilationCutoff' times and clear state |
iignatyev@4908 | 89 | for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { |
iignatyev@4951 | 90 | compileAndDeoptimize(); |
iignatyev@4592 | 91 | } |
iignatyev@5541 | 92 | if (!testCase.isOsr && !isCompilable()) { |
iignatyev@5541 | 93 | // in osr test case count of deopt maybe more than iterations |
iignatyev@4951 | 94 | throw new RuntimeException(method + " is not compilable after " |
iignatyev@4908 | 95 | + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); |
iignatyev@4908 | 96 | } |
iignatyev@4951 | 97 | WHITE_BOX.clearMethodState(method); |
iignatyev@4908 | 98 | |
iignatyev@4951 | 99 | // deoptimize 'PerMethodRecompilationCutoff' + 1 times |
iignatyev@4908 | 100 | long i; |
iignatyev@4908 | 101 | for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF |
iignatyev@5541 | 102 | && isCompilable(); ++i) { |
iignatyev@4951 | 103 | compileAndDeoptimize(); |
iignatyev@4908 | 104 | } |
iignatyev@5541 | 105 | if (!testCase.isOsr && i != PER_METHOD_RECOMPILATION_CUTOFF) { |
iignatyev@5541 | 106 | // in osr test case count of deopt maybe more than iterations |
iignatyev@4951 | 107 | throw new RuntimeException(method + " is not compilable after " |
iignatyev@4951 | 108 | + i + " iterations, but must only after " |
iignatyev@4951 | 109 | + PER_METHOD_RECOMPILATION_CUTOFF); |
iignatyev@4908 | 110 | } |
iignatyev@5541 | 111 | if (isCompilable()) { |
iignatyev@4951 | 112 | throw new RuntimeException(method + " is still compilable after " |
iignatyev@4592 | 113 | + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
iignatyev@4592 | 114 | } |
iignatyev@4592 | 115 | compile(); |
iignatyev@4951 | 116 | checkNotCompiled(); |
iignatyev@4908 | 117 | |
iignatyev@4951 | 118 | // WB.clearMethodState() must reset no-compilable flags |
iignatyev@4951 | 119 | WHITE_BOX.clearMethodState(method); |
iignatyev@5541 | 120 | if (!isCompilable()) { |
iignatyev@4951 | 121 | throw new RuntimeException(method |
iignatyev@4951 | 122 | + " is not compilable after clearMethodState()"); |
iignatyev@4592 | 123 | } |
iignatyev@4908 | 124 | compile(); |
iignatyev@4951 | 125 | checkCompiled(); |
iignatyev@4908 | 126 | } |
iignatyev@4908 | 127 | |
iignatyev@4951 | 128 | private void compileAndDeoptimize() throws Exception { |
iignatyev@4908 | 129 | compile(); |
iignatyev@4951 | 130 | waitBackgroundCompilation(); |
iignatyev@5541 | 131 | deoptimize(); |
iignatyev@4592 | 132 | } |
iignatyev@4592 | 133 | } |