test/compiler/whitebox/MakeMethodNotCompilableTest.java

Thu, 06 Mar 2014 12:47:45 +0400

author
iignatyev
date
Thu, 06 Mar 2014 12:47:45 +0400
changeset 6353
d559dbbded7a
parent 6211
d1760952ebdd
child 6876
710a3c8b516e
child 7318
c88a4554854c
permissions
-rw-r--r--

8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
Reviewed-by: kvn, roland

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 MakeMethodNotCompilableTest
iignatyev@5541 26 * @bug 8012322 8006683 8007288 8022832
mgerdin@4637 27 * @library /testlibrary /testlibrary/whitebox
mgerdin@4637 28 * @build MakeMethodNotCompilableTest
mgerdin@4637 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox
iignatyev@6211 30 * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* MakeMethodNotCompilableTest
iignatyev@4951 31 * @summary testing of WB::makeMethodNotCompilable()
iignatyev@4592 32 * @author igor.ignatyev@oracle.com
iignatyev@4592 33 */
iignatyev@4592 34 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
iignatyev@5541 35 private int bci;
iignatyev@4592 36 public static void main(String[] args) throws Exception {
iignatyev@6211 37 CompilerWhiteBoxTest.main(MakeMethodNotCompilableTest::new, args);
iignatyev@4592 38 }
iignatyev@4592 39
iignatyev@6211 40 private MakeMethodNotCompilableTest(TestCase testCase) {
iignatyev@4951 41 super(testCase);
iignatyev@4951 42 // to prevent inlining of #method
iignatyev@4951 43 WHITE_BOX.testSetDontInlineMethod(method, true);
iignatyev@4951 44 }
iignatyev@4951 45
iignatyev@4951 46 /**
iignatyev@4951 47 * Tests {@code WB::makeMethodNotCompilable()} by calling it before
iignatyev@4951 48 * compilation and checking that method isn't compiled. Also
iignatyev@4951 49 * checks that WB::clearMethodState() clears no-compilable flags. For
iignatyev@4951 50 * tiered, additional checks for all available levels are conducted.
iignatyev@4951 51 *
iignatyev@4951 52 * @throws Exception if one of the checks fails.
iignatyev@4951 53 */
iignatyev@4951 54 @Override
iignatyev@4951 55 protected void test() throws Exception {
iignatyev@6353 56 if (skipXcompOSR()) {
iignatyev@6353 57 return;
iignatyev@5796 58 }
iignatyev@4951 59 checkNotCompiled();
iignatyev@5541 60 if (!isCompilable()) {
iignatyev@4951 61 throw new RuntimeException(method + " must be compilable");
iignatyev@4592 62 }
iignatyev@4951 63
iignatyev@5541 64 bci = getBci();
iignatyev@5541 65
iignatyev@4951 66 if (TIERED_COMPILATION) {
iignatyev@5032 67 final int tierLimit = TIERED_STOP_AT_LEVEL + 1;
iignatyev@5032 68 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
iignatyev@5032 69 testTier(testedTier);
iignatyev@5032 70 }
iignatyev@5032 71 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
iignatyev@5541 72 makeNotCompilable(testedTier);
iignatyev@5541 73 if (isCompilable(testedTier)) {
iignatyev@4951 74 throw new RuntimeException(method
iignatyev@5032 75 + " must be not compilable at level" + testedTier);
iignatyev@4951 76 }
iignatyev@5541 77 WHITE_BOX.enqueueMethodForCompilation(method, testedTier, bci);
iignatyev@4951 78 checkNotCompiled();
iignatyev@4951 79
iignatyev@5541 80 if (!isCompilable()) {
iignatyev@4951 81 System.out.println(method
iignatyev@5032 82 + " is not compilable after level " + testedTier);
iignatyev@4951 83 }
iignatyev@4951 84 }
iignatyev@5032 85 } else {
iignatyev@5032 86 compile();
iignatyev@5032 87 checkCompiled();
iignatyev@5541 88 int compLevel = getCompLevel();
iignatyev@5541 89 deoptimize();
iignatyev@5541 90 makeNotCompilable(compLevel);
iignatyev@5541 91 if (isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 92 throw new RuntimeException(method
iignatyev@5032 93 + " must be not compilable at CompLevel::CompLevel_any,"
iignatyev@5032 94 + " after it is not compilable at " + compLevel);
iignatyev@5032 95 }
iignatyev@5541 96
iignatyev@5032 97 WHITE_BOX.clearMethodState(method);
iignatyev@5541 98 if (!isCompilable()) {
iignatyev@5541 99 throw new RuntimeException(method
iignatyev@5541 100 + " is not compilable after clearMethodState()");
iignatyev@5541 101 }
iignatyev@4951 102
iignatyev@5032 103 // nocompilable at opposite level must make no sense
iignatyev@5032 104 int oppositeLevel;
iignatyev@5032 105 if (isC1Compile(compLevel)) {
iignatyev@5032 106 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION;
iignatyev@5032 107 } else {
iignatyev@5032 108 oppositeLevel = COMP_LEVEL_SIMPLE;
iignatyev@5032 109 }
iignatyev@5541 110 makeNotCompilable(oppositeLevel);
iignatyev@5032 111
iignatyev@5541 112 if (!isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 113 throw new RuntimeException(method
iignatyev@5032 114 + " must be compilable at CompLevel::CompLevel_any,"
iignatyev@5032 115 + " even it is not compilable at opposite level ["
iignatyev@5032 116 + compLevel + "]");
iignatyev@5032 117 }
iignatyev@5032 118
iignatyev@5541 119 if (!isCompilable(compLevel)) {
iignatyev@5032 120 throw new RuntimeException(method
iignatyev@5032 121 + " must be compilable at level " + compLevel
iignatyev@5032 122 + ", even it is not compilable at opposite level ["
iignatyev@5032 123 + compLevel + "]");
iignatyev@4951 124 }
iignatyev@4951 125 }
iignatyev@5032 126
iignatyev@5032 127 // clearing after tiered/non-tiered tests
iignatyev@5032 128 // WB.clearMethodState() must reset no-compilable flags
iignatyev@5032 129 WHITE_BOX.clearMethodState(method);
iignatyev@5541 130 if (!isCompilable()) {
iignatyev@5032 131 throw new RuntimeException(method
iignatyev@5032 132 + " is not compilable after clearMethodState()");
iignatyev@5032 133 }
iignatyev@5032 134
iignatyev@5541 135 makeNotCompilable();
iignatyev@5541 136 if (isCompilable()) {
iignatyev@4951 137 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 138 }
iignatyev@4951 139
iignatyev@4951 140 compile();
iignatyev@4951 141 checkNotCompiled();
iignatyev@5541 142 if (isCompilable()) {
iignatyev@4951 143 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 144 }
iignatyev@4951 145 // WB.clearMethodState() must reset no-compilable flags
iignatyev@4951 146 WHITE_BOX.clearMethodState(method);
iignatyev@5541 147 if (!isCompilable()) {
iignatyev@4951 148 throw new RuntimeException(method
iignatyev@4951 149 + " is not compilable after clearMethodState()");
iignatyev@4592 150 }
iignatyev@4592 151 compile();
iignatyev@4951 152 checkCompiled();
iignatyev@4592 153 }
iignatyev@5032 154
iignatyev@5032 155 // separately tests each tier
iignatyev@5032 156 private void testTier(int testedTier) {
iignatyev@5541 157 if (!isCompilable(testedTier)) {
iignatyev@5032 158 throw new RuntimeException(method
iignatyev@5032 159 + " is not compilable on start");
iignatyev@5032 160 }
iignatyev@5541 161 makeNotCompilable(testedTier);
iignatyev@5032 162
iignatyev@5032 163 // tests for all other tiers
iignatyev@5032 164 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1;
iignatyev@5032 165 anotherTier < tierLimit; ++anotherTier) {
iignatyev@5541 166 boolean isCompilable = isCompilable(anotherTier);
iignatyev@5032 167 if (sameCompile(testedTier, anotherTier)) {
iignatyev@5032 168 if (isCompilable) {
iignatyev@5032 169 throw new RuntimeException(method
iignatyev@5032 170 + " must be not compilable at level " + anotherTier
iignatyev@5032 171 + ", if it is not compilable at " + testedTier);
iignatyev@5032 172 }
iignatyev@5541 173 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
iignatyev@5032 174 checkNotCompiled();
iignatyev@5032 175 } else {
iignatyev@5032 176 if (!isCompilable) {
iignatyev@5032 177 throw new RuntimeException(method
iignatyev@5032 178 + " must be compilable at level " + anotherTier
iignatyev@5032 179 + ", even if it is not compilable at "
iignatyev@5032 180 + testedTier);
iignatyev@5032 181 }
iignatyev@5541 182 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
iignatyev@5032 183 checkCompiled();
iignatyev@5541 184 deoptimize();
iignatyev@5032 185 }
iignatyev@5032 186
iignatyev@5541 187 if (!isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 188 throw new RuntimeException(method
iignatyev@5032 189 + " must be compilable at 'CompLevel::CompLevel_any'"
iignatyev@5032 190 + ", if it is not compilable only at " + testedTier);
iignatyev@5032 191 }
iignatyev@5032 192 }
iignatyev@5032 193
iignatyev@5032 194 // clear state after test
iignatyev@5032 195 WHITE_BOX.clearMethodState(method);
iignatyev@5541 196 if (!isCompilable(testedTier)) {
iignatyev@5032 197 throw new RuntimeException(method
iignatyev@5032 198 + " is not compilable after clearMethodState()");
iignatyev@5032 199 }
iignatyev@5032 200 }
iignatyev@5032 201
iignatyev@5032 202 private boolean sameCompile(int level1, int level2) {
iignatyev@5032 203 if (level1 == level2) {
iignatyev@5032 204 return true;
iignatyev@5032 205 }
iignatyev@5032 206 if (isC1Compile(level1) && isC1Compile(level2)) {
iignatyev@5032 207 return true;
iignatyev@5032 208 }
iignatyev@5032 209 if (isC2Compile(level1) && isC2Compile(level2)) {
iignatyev@5032 210 return true;
iignatyev@5032 211 }
iignatyev@5032 212 return false;
iignatyev@5032 213 }
iignatyev@5541 214
iignatyev@5541 215 private int getBci() {
iignatyev@5541 216 compile();
iignatyev@5541 217 checkCompiled();
iignatyev@5541 218 int result = WHITE_BOX.getMethodEntryBci(method);
iignatyev@5541 219 deoptimize();
iignatyev@5541 220 WHITE_BOX.clearMethodState(method);
iignatyev@5541 221 return result;
iignatyev@5541 222 }
iignatyev@4592 223 }

mercurial