test/compiler/whitebox/MakeMethodNotCompilableTest.java

changeset 4951
4b2eebe03f93
parent 4908
b84fd7d73702
child 5032
d1c9384eecb4
     1.1 --- a/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Tue Apr 16 10:37:16 2013 -0400
     1.2 +++ b/test/compiler/whitebox/MakeMethodNotCompilableTest.java	Tue Apr 16 10:04:01 2013 -0700
     1.3 @@ -27,28 +27,85 @@
     1.4   * @build MakeMethodNotCompilableTest
     1.5   * @run main ClassFileInstaller sun.hotspot.WhiteBox
     1.6   * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI MakeMethodNotCompilableTest
     1.7 + * @summary testing of WB::makeMethodNotCompilable()
     1.8   * @author igor.ignatyev@oracle.com
     1.9   */
    1.10  public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
    1.11  
    1.12      public static void main(String[] args) throws Exception {
    1.13 -        // to prevent inlining #method into #compile()
    1.14 -        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
    1.15 -        new MakeMethodNotCompilableTest().runTest();
    1.16 +        if (args.length == 0) {
    1.17 +            for (TestCase test : TestCase.values()) {
    1.18 +                new MakeMethodNotCompilableTest(test).runTest();
    1.19 +            }
    1.20 +        } else {
    1.21 +            for (String name : args) {
    1.22 +                new MakeMethodNotCompilableTest(
    1.23 +                        TestCase.valueOf(name)).runTest();
    1.24 +            }
    1.25 +        }
    1.26      }
    1.27  
    1.28 -    protected void test() throws Exception  {
    1.29 -        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
    1.30 -            throw new RuntimeException(METHOD + " must be compilable");
    1.31 +    public MakeMethodNotCompilableTest(TestCase testCase) {
    1.32 +        super(testCase);
    1.33 +        // to prevent inlining of #method
    1.34 +        WHITE_BOX.testSetDontInlineMethod(method, true);
    1.35 +    }
    1.36 +
    1.37 +    /**
    1.38 +     * Tests {@code WB::makeMethodNotCompilable()} by calling it before
    1.39 +     * compilation and checking that method isn't compiled. Also
    1.40 +     * checks that WB::clearMethodState() clears no-compilable flags. For
    1.41 +     * tiered, additional checks for all available levels are conducted.
    1.42 +     *
    1.43 +     * @throws Exception if one of the checks fails.
    1.44 +     */
    1.45 +    @Override
    1.46 +    protected void test() throws Exception {
    1.47 +        checkNotCompiled();
    1.48 +        if (!WHITE_BOX.isMethodCompilable(method)) {
    1.49 +            throw new RuntimeException(method + " must be compilable");
    1.50          }
    1.51 -        WHITE_BOX.makeMethodNotCompilable(METHOD);
    1.52 -        if (WHITE_BOX.isMethodCompilable(METHOD)) {
    1.53 -            throw new RuntimeException(METHOD + " must be not compilable");
    1.54 +
    1.55 +        if (TIERED_COMPILATION) {
    1.56 +            for (int i = 1, n = TIERED_STOP_AT_LEVEL + 1; i < n; ++i) {
    1.57 +                WHITE_BOX.makeMethodNotCompilable(method, i);
    1.58 +                if (WHITE_BOX.isMethodCompilable(method, i)) {
    1.59 +                    throw new RuntimeException(method
    1.60 +                            + " must be not compilable at level" + i);
    1.61 +                }
    1.62 +                WHITE_BOX.enqueueMethodForCompilation(method, i);
    1.63 +                checkNotCompiled();
    1.64 +
    1.65 +                if (!WHITE_BOX.isMethodCompilable(method)) {
    1.66 +                    System.out.println(method
    1.67 +                            + " is not compilable after level " + i);
    1.68 +                }
    1.69 +            }
    1.70 +
    1.71 +            // WB.clearMethodState() must reset no-compilable flags
    1.72 +            WHITE_BOX.clearMethodState(method);
    1.73 +            if (!WHITE_BOX.isMethodCompilable(method)) {
    1.74 +                throw new RuntimeException(method
    1.75 +                        + " is not compilable after clearMethodState()");
    1.76 +            }
    1.77 +        }
    1.78 +        WHITE_BOX.makeMethodNotCompilable(method);
    1.79 +        if (WHITE_BOX.isMethodCompilable(method)) {
    1.80 +            throw new RuntimeException(method + " must be not compilable");
    1.81 +        }
    1.82 +
    1.83 +        compile();
    1.84 +        checkNotCompiled();
    1.85 +        if (WHITE_BOX.isMethodCompilable(method)) {
    1.86 +            throw new RuntimeException(method + " must be not compilable");
    1.87 +        }
    1.88 +        // WB.clearMethodState() must reset no-compilable flags
    1.89 +        WHITE_BOX.clearMethodState(method);
    1.90 +        if (!WHITE_BOX.isMethodCompilable(method)) {
    1.91 +            throw new RuntimeException(method
    1.92 +                    + " is not compilable after clearMethodState()");
    1.93          }
    1.94          compile();
    1.95 -        checkNotCompiled(METHOD);
    1.96 -        if (WHITE_BOX.isMethodCompilable(METHOD)) {
    1.97 -            throw new RuntimeException(METHOD + " must be not compilable");
    1.98 -        }
    1.99 +        checkCompiled();
   1.100      }
   1.101  }

mercurial