test/compiler/whitebox/IsMethodCompilableTest.java

Wed, 28 Aug 2013 19:25:18 -0400

author
dholmes
date
Wed, 28 Aug 2013 19:25:18 -0400
changeset 5590
2b113b65a051
parent 5541
f99558245e5c
child 5796
303826f477c6
permissions
-rw-r--r--

8023900: [TESTBUG] Initial compact profile test groups need adjusting
Reviewed-by: dcubed, mchung, hseigel

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@5541 71 if (!isCompilable()) {
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@5541 86 if (!testCase.isOsr && !isCompilable()) {
iignatyev@5541 87 // in osr test case count of deopt maybe more than iterations
iignatyev@4951 88 throw new RuntimeException(method + " is not compilable after "
iignatyev@4908 89 + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
iignatyev@4908 90 }
iignatyev@4951 91 WHITE_BOX.clearMethodState(method);
iignatyev@4908 92
iignatyev@4951 93 // deoptimize 'PerMethodRecompilationCutoff' + 1 times
iignatyev@4908 94 long i;
iignatyev@4908 95 for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
iignatyev@5541 96 && isCompilable(); ++i) {
iignatyev@4951 97 compileAndDeoptimize();
iignatyev@4908 98 }
iignatyev@5541 99 if (!testCase.isOsr && i != PER_METHOD_RECOMPILATION_CUTOFF) {
iignatyev@5541 100 // in osr test case count of deopt maybe more than iterations
iignatyev@4951 101 throw new RuntimeException(method + " is not compilable after "
iignatyev@4951 102 + i + " iterations, but must only after "
iignatyev@4951 103 + PER_METHOD_RECOMPILATION_CUTOFF);
iignatyev@4908 104 }
iignatyev@5541 105 if (isCompilable()) {
iignatyev@4951 106 throw new RuntimeException(method + " is still compilable after "
iignatyev@4592 107 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
iignatyev@4592 108 }
iignatyev@4592 109 compile();
iignatyev@4951 110 checkNotCompiled();
iignatyev@4908 111
iignatyev@4951 112 // WB.clearMethodState() must reset no-compilable flags
iignatyev@4951 113 WHITE_BOX.clearMethodState(method);
iignatyev@5541 114 if (!isCompilable()) {
iignatyev@4951 115 throw new RuntimeException(method
iignatyev@4951 116 + " is not compilable after clearMethodState()");
iignatyev@4592 117 }
iignatyev@4908 118 compile();
iignatyev@4951 119 checkCompiled();
iignatyev@4908 120 }
iignatyev@4908 121
iignatyev@4951 122 private void compileAndDeoptimize() throws Exception {
iignatyev@4908 123 compile();
iignatyev@4951 124 waitBackgroundCompilation();
iignatyev@5541 125 deoptimize();
iignatyev@4592 126 }
iignatyev@4592 127 }

mercurial