Thu, 17 Apr 2014 16:09:08 -0700
Added tag hs25.20-b11 for changeset b6a2ba7d3ea7
iignatyev@4592 | 1 | /* |
iignatyev@6353 | 2 | * Copyright (c) 2013, 2014, 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 |
neliasso@6612 | 27 | * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary |
mgerdin@4637 | 28 | * @build IsMethodCompilableTest |
mgerdin@4637 | 29 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
neliasso@6612 | 30 | * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform |
neliasso@6612 | 31 | * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest |
iignatyev@4951 | 32 | * @summary testing of WB::isMethodCompilable() |
iignatyev@4592 | 33 | * @author igor.ignatyev@oracle.com |
iignatyev@4592 | 34 | */ |
neliasso@6612 | 35 | |
neliasso@6612 | 36 | import com.oracle.java.testlibrary.Platform; |
neliasso@6612 | 37 | |
iignatyev@4592 | 38 | public class IsMethodCompilableTest extends CompilerWhiteBoxTest { |
iignatyev@4951 | 39 | /** |
iignatyev@4951 | 40 | * Value of {@code -XX:PerMethodRecompilationCutoff} |
iignatyev@4951 | 41 | */ |
iignatyev@4592 | 42 | protected static final long PER_METHOD_RECOMPILATION_CUTOFF; |
iignatyev@4592 | 43 | |
iignatyev@4592 | 44 | static { |
iignatyev@4592 | 45 | long tmp = Long.parseLong( |
iignatyev@4592 | 46 | getVMOption("PerMethodRecompilationCutoff", "400")); |
iignatyev@4592 | 47 | if (tmp == -1) { |
iignatyev@4592 | 48 | PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; |
iignatyev@4592 | 49 | } else { |
neliasso@6612 | 50 | PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp); |
iignatyev@4592 | 51 | } |
iignatyev@4592 | 52 | } |
iignatyev@4592 | 53 | |
iignatyev@4592 | 54 | public static void main(String[] args) throws Exception { |
iignatyev@6211 | 55 | CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args); |
iignatyev@4592 | 56 | } |
iignatyev@4592 | 57 | |
iignatyev@6211 | 58 | private IsMethodCompilableTest(TestCase testCase) { |
iignatyev@4951 | 59 | super(testCase); |
iignatyev@4951 | 60 | // to prevent inlining of #method |
iignatyev@4951 | 61 | WHITE_BOX.testSetDontInlineMethod(method, true); |
iignatyev@4951 | 62 | } |
iignatyev@4951 | 63 | |
iignatyev@4951 | 64 | /** |
iignatyev@4951 | 65 | * Tests {@code WB::isMethodCompilable()} by recompilation of tested method |
iignatyev@4951 | 66 | * 'PerMethodRecompilationCutoff' times and checks compilation status. Also |
neliasso@6612 | 67 | * checks that WB::clearMethodState() clears no-compilable flags. Only |
neliasso@6612 | 68 | * applicable to c2 compiled methods. |
iignatyev@4951 | 69 | * |
iignatyev@4951 | 70 | * @throws Exception if one of the checks fails. |
iignatyev@4951 | 71 | */ |
iignatyev@4951 | 72 | @Override |
iignatyev@4592 | 73 | protected void test() throws Exception { |
neliasso@6612 | 74 | // Only c2 compilations can be disabled through PerMethodRecompilationCutoff |
neliasso@6612 | 75 | if (!Platform.isServer()) { |
neliasso@6612 | 76 | return; |
neliasso@6612 | 77 | } |
neliasso@6612 | 78 | |
iignatyev@6353 | 79 | if (skipXcompOSR()) { |
iignatyev@5796 | 80 | return; |
iignatyev@5796 | 81 | } |
neliasso@6612 | 82 | if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
iignatyev@4951 | 83 | throw new RuntimeException(method + " must be compilable"); |
iignatyev@4592 | 84 | } |
iignatyev@4592 | 85 | System.out.println("PerMethodRecompilationCutoff = " |
iignatyev@4592 | 86 | + PER_METHOD_RECOMPILATION_CUTOFF); |
iignatyev@4592 | 87 | if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
iignatyev@4592 | 88 | System.err.println( |
iignatyev@4592 | 89 | "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
iignatyev@4592 | 90 | return; |
iignatyev@4592 | 91 | } |
iignatyev@4592 | 92 | |
neliasso@6612 | 93 | // deoptimize 'PerMethodRecompilationCutoff' times |
neliasso@6612 | 94 | for (long attempts = 0, successes = 0; |
neliasso@6612 | 95 | (successes < PER_METHOD_RECOMPILATION_CUTOFF) && |
neliasso@6612 | 96 | (attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) && |
neliasso@6612 | 97 | isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) { |
neliasso@6612 | 98 | if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) { |
neliasso@6612 | 99 | successes++; |
neliasso@6612 | 100 | } |
iignatyev@4592 | 101 | } |
neliasso@6612 | 102 | |
neliasso@6612 | 103 | if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
iignatyev@5541 | 104 | // in osr test case count of deopt maybe more than iterations |
iignatyev@4951 | 105 | throw new RuntimeException(method + " is not compilable after " |
neliasso@6612 | 106 | + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
iignatyev@4908 | 107 | } |
iignatyev@4908 | 108 | |
neliasso@6612 | 109 | // Now compile once more |
neliasso@6612 | 110 | compileAndDeoptimize(); |
neliasso@6612 | 111 | |
neliasso@6612 | 112 | if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
iignatyev@4951 | 113 | throw new RuntimeException(method + " is still compilable after " |
iignatyev@4592 | 114 | + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
iignatyev@4592 | 115 | } |
neliasso@6612 | 116 | checkNotCompiled(); |
iignatyev@4592 | 117 | compile(); |
neliasso@6612 | 118 | waitBackgroundCompilation(); |
neliasso@6612 | 119 | checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION); |
iignatyev@4908 | 120 | |
iignatyev@4951 | 121 | // WB.clearMethodState() must reset no-compilable flags |
iignatyev@4951 | 122 | WHITE_BOX.clearMethodState(method); |
neliasso@6612 | 123 | if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
iignatyev@4951 | 124 | throw new RuntimeException(method |
iignatyev@4951 | 125 | + " is not compilable after clearMethodState()"); |
iignatyev@4592 | 126 | } |
iignatyev@4908 | 127 | compile(); |
iignatyev@4951 | 128 | checkCompiled(); |
iignatyev@4908 | 129 | } |
iignatyev@4908 | 130 | |
neliasso@6612 | 131 | private int compileAndDeoptimize() throws Exception { |
iignatyev@4908 | 132 | compile(); |
iignatyev@4951 | 133 | waitBackgroundCompilation(); |
neliasso@6612 | 134 | int compLevel = getCompLevel(); |
iignatyev@5541 | 135 | deoptimize(); |
neliasso@6612 | 136 | return compLevel; |
iignatyev@4592 | 137 | } |
iignatyev@4592 | 138 | } |