test/compiler/whitebox/MakeMethodNotCompilableTest.java

Tue, 31 Dec 2013 19:26:57 +0400

author
iignatyev
date
Tue, 31 Dec 2013 19:26:57 +0400
changeset 6211
d1760952ebdd
parent 5796
303826f477c6
child 6353
d559dbbded7a
permissions
-rw-r--r--

8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
Reviewed-by: twisti
Contributed-by: anton.ivanov@oracle.com

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@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@6211 56 if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith(
iignatyev@5796 57 "compiled ")) {
iignatyev@5796 58 System.err.printf("Warning: %s is not applicable in %s%n",
iignatyev@5796 59 testCase.name(), CompilerWhiteBoxTest.MODE);
iignatyev@5796 60 return;
iignatyev@5796 61 }
iignatyev@4951 62 checkNotCompiled();
iignatyev@5541 63 if (!isCompilable()) {
iignatyev@4951 64 throw new RuntimeException(method + " must be compilable");
iignatyev@4592 65 }
iignatyev@4951 66
iignatyev@5541 67 bci = getBci();
iignatyev@5541 68
iignatyev@4951 69 if (TIERED_COMPILATION) {
iignatyev@5032 70 final int tierLimit = TIERED_STOP_AT_LEVEL + 1;
iignatyev@5032 71 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
iignatyev@5032 72 testTier(testedTier);
iignatyev@5032 73 }
iignatyev@5032 74 for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
iignatyev@5541 75 makeNotCompilable(testedTier);
iignatyev@5541 76 if (isCompilable(testedTier)) {
iignatyev@4951 77 throw new RuntimeException(method
iignatyev@5032 78 + " must be not compilable at level" + testedTier);
iignatyev@4951 79 }
iignatyev@5541 80 WHITE_BOX.enqueueMethodForCompilation(method, testedTier, bci);
iignatyev@4951 81 checkNotCompiled();
iignatyev@4951 82
iignatyev@5541 83 if (!isCompilable()) {
iignatyev@4951 84 System.out.println(method
iignatyev@5032 85 + " is not compilable after level " + testedTier);
iignatyev@4951 86 }
iignatyev@4951 87 }
iignatyev@5032 88 } else {
iignatyev@5032 89 compile();
iignatyev@5032 90 checkCompiled();
iignatyev@5541 91 int compLevel = getCompLevel();
iignatyev@5541 92 deoptimize();
iignatyev@5541 93 makeNotCompilable(compLevel);
iignatyev@5541 94 if (isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 95 throw new RuntimeException(method
iignatyev@5032 96 + " must be not compilable at CompLevel::CompLevel_any,"
iignatyev@5032 97 + " after it is not compilable at " + compLevel);
iignatyev@5032 98 }
iignatyev@5541 99
iignatyev@5032 100 WHITE_BOX.clearMethodState(method);
iignatyev@5541 101 if (!isCompilable()) {
iignatyev@5541 102 throw new RuntimeException(method
iignatyev@5541 103 + " is not compilable after clearMethodState()");
iignatyev@5541 104 }
iignatyev@4951 105
iignatyev@5032 106 // nocompilable at opposite level must make no sense
iignatyev@5032 107 int oppositeLevel;
iignatyev@5032 108 if (isC1Compile(compLevel)) {
iignatyev@5032 109 oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION;
iignatyev@5032 110 } else {
iignatyev@5032 111 oppositeLevel = COMP_LEVEL_SIMPLE;
iignatyev@5032 112 }
iignatyev@5541 113 makeNotCompilable(oppositeLevel);
iignatyev@5032 114
iignatyev@5541 115 if (!isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 116 throw new RuntimeException(method
iignatyev@5032 117 + " must be compilable at CompLevel::CompLevel_any,"
iignatyev@5032 118 + " even it is not compilable at opposite level ["
iignatyev@5032 119 + compLevel + "]");
iignatyev@5032 120 }
iignatyev@5032 121
iignatyev@5541 122 if (!isCompilable(compLevel)) {
iignatyev@5032 123 throw new RuntimeException(method
iignatyev@5032 124 + " must be compilable at level " + compLevel
iignatyev@5032 125 + ", even it is not compilable at opposite level ["
iignatyev@5032 126 + compLevel + "]");
iignatyev@4951 127 }
iignatyev@4951 128 }
iignatyev@5032 129
iignatyev@5032 130 // clearing after tiered/non-tiered tests
iignatyev@5032 131 // WB.clearMethodState() must reset no-compilable flags
iignatyev@5032 132 WHITE_BOX.clearMethodState(method);
iignatyev@5541 133 if (!isCompilable()) {
iignatyev@5032 134 throw new RuntimeException(method
iignatyev@5032 135 + " is not compilable after clearMethodState()");
iignatyev@5032 136 }
iignatyev@5032 137
iignatyev@5541 138 makeNotCompilable();
iignatyev@5541 139 if (isCompilable()) {
iignatyev@4951 140 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 141 }
iignatyev@4951 142
iignatyev@4951 143 compile();
iignatyev@4951 144 checkNotCompiled();
iignatyev@5541 145 if (isCompilable()) {
iignatyev@4951 146 throw new RuntimeException(method + " must be not compilable");
iignatyev@4951 147 }
iignatyev@4951 148 // WB.clearMethodState() must reset no-compilable flags
iignatyev@4951 149 WHITE_BOX.clearMethodState(method);
iignatyev@5541 150 if (!isCompilable()) {
iignatyev@4951 151 throw new RuntimeException(method
iignatyev@4951 152 + " is not compilable after clearMethodState()");
iignatyev@4592 153 }
iignatyev@4592 154 compile();
iignatyev@4951 155 checkCompiled();
iignatyev@4592 156 }
iignatyev@5032 157
iignatyev@5032 158 // separately tests each tier
iignatyev@5032 159 private void testTier(int testedTier) {
iignatyev@5541 160 if (!isCompilable(testedTier)) {
iignatyev@5032 161 throw new RuntimeException(method
iignatyev@5032 162 + " is not compilable on start");
iignatyev@5032 163 }
iignatyev@5541 164 makeNotCompilable(testedTier);
iignatyev@5032 165
iignatyev@5032 166 // tests for all other tiers
iignatyev@5032 167 for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1;
iignatyev@5032 168 anotherTier < tierLimit; ++anotherTier) {
iignatyev@5541 169 boolean isCompilable = isCompilable(anotherTier);
iignatyev@5032 170 if (sameCompile(testedTier, anotherTier)) {
iignatyev@5032 171 if (isCompilable) {
iignatyev@5032 172 throw new RuntimeException(method
iignatyev@5032 173 + " must be not compilable at level " + anotherTier
iignatyev@5032 174 + ", if it is not compilable at " + testedTier);
iignatyev@5032 175 }
iignatyev@5541 176 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
iignatyev@5032 177 checkNotCompiled();
iignatyev@5032 178 } else {
iignatyev@5032 179 if (!isCompilable) {
iignatyev@5032 180 throw new RuntimeException(method
iignatyev@5032 181 + " must be compilable at level " + anotherTier
iignatyev@5032 182 + ", even if it is not compilable at "
iignatyev@5032 183 + testedTier);
iignatyev@5032 184 }
iignatyev@5541 185 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
iignatyev@5032 186 checkCompiled();
iignatyev@5541 187 deoptimize();
iignatyev@5032 188 }
iignatyev@5032 189
iignatyev@5541 190 if (!isCompilable(COMP_LEVEL_ANY)) {
iignatyev@5032 191 throw new RuntimeException(method
iignatyev@5032 192 + " must be compilable at 'CompLevel::CompLevel_any'"
iignatyev@5032 193 + ", if it is not compilable only at " + testedTier);
iignatyev@5032 194 }
iignatyev@5032 195 }
iignatyev@5032 196
iignatyev@5032 197 // clear state after test
iignatyev@5032 198 WHITE_BOX.clearMethodState(method);
iignatyev@5541 199 if (!isCompilable(testedTier)) {
iignatyev@5032 200 throw new RuntimeException(method
iignatyev@5032 201 + " is not compilable after clearMethodState()");
iignatyev@5032 202 }
iignatyev@5032 203 }
iignatyev@5032 204
iignatyev@5032 205 private boolean sameCompile(int level1, int level2) {
iignatyev@5032 206 if (level1 == level2) {
iignatyev@5032 207 return true;
iignatyev@5032 208 }
iignatyev@5032 209 if (isC1Compile(level1) && isC1Compile(level2)) {
iignatyev@5032 210 return true;
iignatyev@5032 211 }
iignatyev@5032 212 if (isC2Compile(level1) && isC2Compile(level2)) {
iignatyev@5032 213 return true;
iignatyev@5032 214 }
iignatyev@5032 215 return false;
iignatyev@5032 216 }
iignatyev@5541 217
iignatyev@5541 218 private int getBci() {
iignatyev@5541 219 compile();
iignatyev@5541 220 checkCompiled();
iignatyev@5541 221 int result = WHITE_BOX.getMethodEntryBci(method);
iignatyev@5541 222 deoptimize();
iignatyev@5541 223 WHITE_BOX.clearMethodState(method);
iignatyev@5541 224 return result;
iignatyev@5541 225 }
iignatyev@4592 226 }

mercurial