test/compiler/whitebox/IsMethodCompilableTest.java

changeset 4951
4b2eebe03f93
parent 4908
b84fd7d73702
child 5512
11237ee74aae
     1.1 --- a/test/compiler/whitebox/IsMethodCompilableTest.java	Tue Apr 16 10:37:16 2013 -0400
     1.2 +++ b/test/compiler/whitebox/IsMethodCompilableTest.java	Tue Apr 16 10:04:01 2013 -0700
     1.3 @@ -28,9 +28,13 @@
     1.4   * @build IsMethodCompilableTest
     1.5   * @run main ClassFileInstaller sun.hotspot.WhiteBox
     1.6   * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IsMethodCompilableTest
     1.7 + * @summary testing of WB::isMethodCompilable()
     1.8   * @author igor.ignatyev@oracle.com
     1.9   */
    1.10  public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
    1.11 +    /**
    1.12 +     * Value of {@code -XX:PerMethodRecompilationCutoff}
    1.13 +     */
    1.14      protected static final long PER_METHOD_RECOMPILATION_CUTOFF;
    1.15  
    1.16      static {
    1.17 @@ -44,14 +48,28 @@
    1.18      }
    1.19  
    1.20      public static void main(String[] args) throws Exception {
    1.21 -        // to prevent inlining #method into #compile()
    1.22 -        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
    1.23 -        new IsMethodCompilableTest().runTest();
    1.24 +        for (TestCase test : TestCase.values()) {
    1.25 +            new IsMethodCompilableTest(test).runTest();
    1.26 +        }
    1.27      }
    1.28  
    1.29 +    public IsMethodCompilableTest(TestCase testCase) {
    1.30 +        super(testCase);
    1.31 +        // to prevent inlining of #method
    1.32 +        WHITE_BOX.testSetDontInlineMethod(method, true);
    1.33 +    }
    1.34 +
    1.35 +    /**
    1.36 +     * Tests {@code WB::isMethodCompilable()} by recompilation of tested method
    1.37 +     * 'PerMethodRecompilationCutoff' times and checks compilation status. Also
    1.38 +     * checks that WB::clearMethodState() clears no-compilable flags.
    1.39 +     *
    1.40 +     * @throws Exception if one of the checks fails.
    1.41 +     */
    1.42 +    @Override
    1.43      protected void test() throws Exception {
    1.44 -        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
    1.45 -            throw new RuntimeException(METHOD + " must be compilable");
    1.46 +        if (!WHITE_BOX.isMethodCompilable(method)) {
    1.47 +            throw new RuntimeException(method + " must be compilable");
    1.48          }
    1.49          System.out.println("PerMethodRecompilationCutoff = "
    1.50                  + PER_METHOD_RECOMPILATION_CUTOFF);
    1.51 @@ -61,46 +79,47 @@
    1.52              return;
    1.53          }
    1.54  
    1.55 -        // deoptimze 'PerMethodRecompilationCutoff' times and clear state
    1.56 +        // deoptimize 'PerMethodRecompilationCutoff' times and clear state
    1.57          for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
    1.58 -            compileAndDeoptimaze();
    1.59 +            compileAndDeoptimize();
    1.60          }
    1.61 -        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
    1.62 -            throw new RuntimeException(METHOD + " is not compilable after "
    1.63 +        if (!WHITE_BOX.isMethodCompilable(method)) {
    1.64 +            throw new RuntimeException(method + " is not compilable after "
    1.65                      + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
    1.66          }
    1.67 -        WHITE_BOX.clearMethodState(METHOD);
    1.68 +        WHITE_BOX.clearMethodState(method);
    1.69  
    1.70 -        // deoptimze 'PerMethodRecompilationCutoff' + 1 times
    1.71 +        // deoptimize 'PerMethodRecompilationCutoff' + 1 times
    1.72          long i;
    1.73          for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
    1.74 -                && WHITE_BOX.isMethodCompilable(METHOD); ++i) {
    1.75 -            compileAndDeoptimaze();
    1.76 +                && WHITE_BOX.isMethodCompilable(method); ++i) {
    1.77 +            compileAndDeoptimize();
    1.78          }
    1.79          if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
    1.80 -           throw new RuntimeException(METHOD + " is not compilable after "
    1.81 -                   + i + " iterations, but must only after "
    1.82 -                   + PER_METHOD_RECOMPILATION_CUTOFF);
    1.83 +            throw new RuntimeException(method + " is not compilable after "
    1.84 +                    + i + " iterations, but must only after "
    1.85 +                    + PER_METHOD_RECOMPILATION_CUTOFF);
    1.86          }
    1.87 -        if (WHITE_BOX.isMethodCompilable(METHOD)) {
    1.88 -            throw new RuntimeException(METHOD + " is still compilable after "
    1.89 +        if (WHITE_BOX.isMethodCompilable(method)) {
    1.90 +            throw new RuntimeException(method + " is still compilable after "
    1.91                      + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
    1.92          }
    1.93          compile();
    1.94 -        checkNotCompiled(METHOD);
    1.95 +        checkNotCompiled();
    1.96  
    1.97 -        WHITE_BOX.clearMethodState(METHOD);
    1.98 -        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
    1.99 -            throw new RuntimeException(METHOD
   1.100 -                    + " is compilable after clearMethodState()");
   1.101 +        // WB.clearMethodState() must reset no-compilable flags
   1.102 +        WHITE_BOX.clearMethodState(method);
   1.103 +        if (!WHITE_BOX.isMethodCompilable(method)) {
   1.104 +            throw new RuntimeException(method
   1.105 +                    + " is not compilable after clearMethodState()");
   1.106          }
   1.107          compile();
   1.108 -        checkCompiled(METHOD);
   1.109 +        checkCompiled();
   1.110      }
   1.111  
   1.112 -    private void compileAndDeoptimaze() throws Exception {
   1.113 +    private void compileAndDeoptimize() throws Exception {
   1.114          compile();
   1.115 -        waitBackgroundCompilation(METHOD);
   1.116 -        WHITE_BOX.deoptimizeMethod(METHOD);
   1.117 +        waitBackgroundCompilation();
   1.118 +        WHITE_BOX.deoptimizeMethod(method);
   1.119      }
   1.120  }

mercurial