test/compiler/whitebox/MakeMethodNotCompilableTest.java

Wed, 22 Jan 2014 12:37:28 -0800

author
katleman
date
Wed, 22 Jan 2014 12:37:28 -0800
changeset 6575
2bac854670c0
parent 5796
303826f477c6
child 6211
d1760952ebdd
permissions
-rw-r--r--

Added tag jdk8u5-b05 for changeset b90de55aca30

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

mercurial