test/compiler/whitebox/MakeMethodNotCompilableTest.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

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test MakeMethodNotCompilableTest
    26  * @bug 8012322 8006683 8007288 8022832
    27  * @library /testlibrary /testlibrary/whitebox
    28  * @build MakeMethodNotCompilableTest
    29  * @run main ClassFileInstaller sun.hotspot.WhiteBox
    30  * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* MakeMethodNotCompilableTest
    31  * @summary testing of WB::makeMethodNotCompilable()
    32  * @author igor.ignatyev@oracle.com
    33  */
    34 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
    35     private int bci;
    36     public static void main(String[] args) throws Exception {
    37         if (args.length == 0) {
    38             for (TestCase test : TestCase.values()) {
    39                 new MakeMethodNotCompilableTest(test).runTest();
    40             }
    41         } else {
    42             for (String name : args) {
    43                 new MakeMethodNotCompilableTest(
    44                         TestCase.valueOf(name)).runTest();
    45             }
    46         }
    47     }
    49     public MakeMethodNotCompilableTest(TestCase testCase) {
    50         super(testCase);
    51         // to prevent inlining of #method
    52         WHITE_BOX.testSetDontInlineMethod(method, true);
    53     }
    55     /**
    56      * Tests {@code WB::makeMethodNotCompilable()} by calling it before
    57      * compilation and checking that method isn't compiled. Also
    58      * checks that WB::clearMethodState() clears no-compilable flags. For
    59      * tiered, additional checks for all available levels are conducted.
    60      *
    61      * @throws Exception if one of the checks fails.
    62      */
    63     @Override
    64     protected void test() throws Exception {
    65         checkNotCompiled();
    66         if (!isCompilable()) {
    67             throw new RuntimeException(method + " must be compilable");
    68         }
    70         bci = getBci();
    72         if (TIERED_COMPILATION) {
    73             final int tierLimit = TIERED_STOP_AT_LEVEL + 1;
    74             for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
    75                 testTier(testedTier);
    76             }
    77             for (int testedTier = 1; testedTier < tierLimit; ++testedTier) {
    78                 makeNotCompilable(testedTier);
    79                 if (isCompilable(testedTier)) {
    80                     throw new RuntimeException(method
    81                             + " must be not compilable at level" + testedTier);
    82                 }
    83                 WHITE_BOX.enqueueMethodForCompilation(method, testedTier, bci);
    84                 checkNotCompiled();
    86                 if (!isCompilable()) {
    87                     System.out.println(method
    88                             + " is not compilable after level " + testedTier);
    89                 }
    90             }
    91         } else {
    92             compile();
    93             checkCompiled();
    94             int compLevel = getCompLevel();
    95             deoptimize();
    96             makeNotCompilable(compLevel);
    97             if (isCompilable(COMP_LEVEL_ANY)) {
    98                 throw new RuntimeException(method
    99                         + " must be not compilable at CompLevel::CompLevel_any,"
   100                         + " after it is not compilable at " + compLevel);
   101             }
   103             WHITE_BOX.clearMethodState(method);
   104             if (!isCompilable()) {
   105                 throw new RuntimeException(method
   106                         + " is not compilable after clearMethodState()");
   107             }
   109             // nocompilable at opposite level must make no sense
   110             int oppositeLevel;
   111             if (isC1Compile(compLevel)) {
   112               oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION;
   113             } else {
   114               oppositeLevel = COMP_LEVEL_SIMPLE;
   115             }
   116             makeNotCompilable(oppositeLevel);
   118             if (!isCompilable(COMP_LEVEL_ANY)) {
   119                   throw new RuntimeException(method
   120                         + " must be compilable at CompLevel::CompLevel_any,"
   121                         + " even it is not compilable at opposite level ["
   122                         + compLevel + "]");
   123             }
   125             if (!isCompilable(compLevel)) {
   126                   throw new RuntimeException(method
   127                         + " must be compilable at level " + compLevel
   128                         + ", even it is not compilable at opposite level ["
   129                         + compLevel + "]");
   130             }
   131         }
   133         // clearing after tiered/non-tiered tests
   134         // WB.clearMethodState() must reset no-compilable flags
   135         WHITE_BOX.clearMethodState(method);
   136         if (!isCompilable()) {
   137             throw new RuntimeException(method
   138                     + " is not compilable after clearMethodState()");
   139         }
   141         makeNotCompilable();
   142         if (isCompilable()) {
   143             throw new RuntimeException(method + " must be not compilable");
   144         }
   146         compile();
   147         checkNotCompiled();
   148         if (isCompilable()) {
   149             throw new RuntimeException(method + " must be not compilable");
   150         }
   151         // WB.clearMethodState() must reset no-compilable flags
   152         WHITE_BOX.clearMethodState(method);
   153         if (!isCompilable()) {
   154             throw new RuntimeException(method
   155                     + " is not compilable after clearMethodState()");
   156         }
   157         compile();
   158         checkCompiled();
   159     }
   161     // separately tests each tier
   162     private void testTier(int testedTier) {
   163         if (!isCompilable(testedTier)) {
   164             throw new RuntimeException(method
   165                     + " is not compilable on start");
   166         }
   167         makeNotCompilable(testedTier);
   169         // tests for all other tiers
   170         for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1;
   171                     anotherTier < tierLimit; ++anotherTier) {
   172             boolean isCompilable = isCompilable(anotherTier);
   173             if (sameCompile(testedTier, anotherTier)) {
   174                 if (isCompilable) {
   175                     throw new RuntimeException(method
   176                             + " must be not compilable at level " + anotherTier
   177                             + ", if it is not compilable at " + testedTier);
   178                 }
   179                 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
   180                 checkNotCompiled();
   181             } else {
   182                 if (!isCompilable) {
   183                     throw new RuntimeException(method
   184                             + " must be compilable at level " + anotherTier
   185                             + ", even if it is not compilable at "
   186                             + testedTier);
   187                 }
   188                 WHITE_BOX.enqueueMethodForCompilation(method, anotherTier, bci);
   189                 checkCompiled();
   190                 deoptimize();
   191             }
   193             if (!isCompilable(COMP_LEVEL_ANY)) {
   194                 throw new RuntimeException(method
   195                         + " must be compilable at 'CompLevel::CompLevel_any'"
   196                         + ", if it is not compilable only at " + testedTier);
   197             }
   198         }
   200         // clear state after test
   201         WHITE_BOX.clearMethodState(method);
   202         if (!isCompilable(testedTier)) {
   203             throw new RuntimeException(method
   204                     + " is not compilable after clearMethodState()");
   205         }
   206     }
   208     private boolean sameCompile(int level1, int level2) {
   209         if (level1 == level2) {
   210             return true;
   211         }
   212         if (isC1Compile(level1) && isC1Compile(level2)) {
   213             return true;
   214         }
   215         if (isC2Compile(level1) && isC2Compile(level2)) {
   216             return true;
   217         }
   218         return false;
   219     }
   221     private int getBci() {
   222         compile();
   223         checkCompiled();
   224         int result = WHITE_BOX.getMethodEntryBci(method);
   225         deoptimize();
   226         WHITE_BOX.clearMethodState(method);
   227         return result;
   228     }
   229 }

mercurial