Tue, 16 Apr 2013 10:04:01 -0700
8011971: WB API doesn't accept j.l.reflect.Constructor
Reviewed-by: kvn, vlivanov
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@4592 | 26 | * @bug 8007270 |
mgerdin@4637 | 27 | * @library /testlibrary /testlibrary/whitebox |
mgerdin@4637 | 28 | * @build IsMethodCompilableTest |
mgerdin@4637 | 29 | * @run main ClassFileInstaller sun.hotspot.WhiteBox |
mgerdin@4637 | 30 | * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI 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@4951 | 71 | if (!WHITE_BOX.isMethodCompilable(method)) { |
iignatyev@4951 | 72 | throw new RuntimeException(method + " must be compilable"); |
iignatyev@4592 | 73 | } |
iignatyev@4592 | 74 | System.out.println("PerMethodRecompilationCutoff = " |
iignatyev@4592 | 75 | + PER_METHOD_RECOMPILATION_CUTOFF); |
iignatyev@4592 | 76 | if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
iignatyev@4592 | 77 | System.err.println( |
iignatyev@4592 | 78 | "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
iignatyev@4592 | 79 | return; |
iignatyev@4592 | 80 | } |
iignatyev@4592 | 81 | |
iignatyev@4951 | 82 | // deoptimize 'PerMethodRecompilationCutoff' times and clear state |
iignatyev@4908 | 83 | for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { |
iignatyev@4951 | 84 | compileAndDeoptimize(); |
iignatyev@4592 | 85 | } |
iignatyev@4951 | 86 | if (!WHITE_BOX.isMethodCompilable(method)) { |
iignatyev@4951 | 87 | throw new RuntimeException(method + " is not compilable after " |
iignatyev@4908 | 88 | + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); |
iignatyev@4908 | 89 | } |
iignatyev@4951 | 90 | WHITE_BOX.clearMethodState(method); |
iignatyev@4908 | 91 | |
iignatyev@4951 | 92 | // deoptimize 'PerMethodRecompilationCutoff' + 1 times |
iignatyev@4908 | 93 | long i; |
iignatyev@4908 | 94 | for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF |
iignatyev@4951 | 95 | && WHITE_BOX.isMethodCompilable(method); ++i) { |
iignatyev@4951 | 96 | compileAndDeoptimize(); |
iignatyev@4908 | 97 | } |
iignatyev@4908 | 98 | if (i != PER_METHOD_RECOMPILATION_CUTOFF) { |
iignatyev@4951 | 99 | throw new RuntimeException(method + " is not compilable after " |
iignatyev@4951 | 100 | + i + " iterations, but must only after " |
iignatyev@4951 | 101 | + PER_METHOD_RECOMPILATION_CUTOFF); |
iignatyev@4908 | 102 | } |
iignatyev@4951 | 103 | if (WHITE_BOX.isMethodCompilable(method)) { |
iignatyev@4951 | 104 | throw new RuntimeException(method + " is still compilable after " |
iignatyev@4592 | 105 | + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
iignatyev@4592 | 106 | } |
iignatyev@4592 | 107 | compile(); |
iignatyev@4951 | 108 | checkNotCompiled(); |
iignatyev@4908 | 109 | |
iignatyev@4951 | 110 | // WB.clearMethodState() must reset no-compilable flags |
iignatyev@4951 | 111 | WHITE_BOX.clearMethodState(method); |
iignatyev@4951 | 112 | if (!WHITE_BOX.isMethodCompilable(method)) { |
iignatyev@4951 | 113 | throw new RuntimeException(method |
iignatyev@4951 | 114 | + " is not compilable after clearMethodState()"); |
iignatyev@4592 | 115 | } |
iignatyev@4908 | 116 | compile(); |
iignatyev@4951 | 117 | checkCompiled(); |
iignatyev@4908 | 118 | } |
iignatyev@4908 | 119 | |
iignatyev@4951 | 120 | private void compileAndDeoptimize() throws Exception { |
iignatyev@4908 | 121 | compile(); |
iignatyev@4951 | 122 | waitBackgroundCompilation(); |
iignatyev@4951 | 123 | WHITE_BOX.deoptimizeMethod(method); |
iignatyev@4592 | 124 | } |
iignatyev@4592 | 125 | } |