test/compiler/whitebox/ClearMethodStateTest.java

changeset 4951
4b2eebe03f93
parent 4908
b84fd7d73702
child 5512
11237ee74aae
     1.1 --- a/test/compiler/whitebox/ClearMethodStateTest.java	Tue Apr 16 10:37:16 2013 -0400
     1.2 +++ b/test/compiler/whitebox/ClearMethodStateTest.java	Tue Apr 16 10:04:01 2013 -0700
     1.3 @@ -27,42 +27,61 @@
     1.4   * @build ClearMethodStateTest
     1.5   * @run main ClassFileInstaller sun.hotspot.WhiteBox
     1.6   * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest
     1.7 + * @summary testing of WB::clearMethodState()
     1.8   * @author igor.ignatyev@oracle.com
     1.9   */
    1.10  public class ClearMethodStateTest extends CompilerWhiteBoxTest {
    1.11 +
    1.12      public static void main(String[] args) throws Exception {
    1.13 -        // to prevent inlining #method into #compile() and #test()
    1.14 -        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
    1.15 -        new ClearMethodStateTest().runTest();
    1.16 +        for (TestCase test : TestCase.values()) {
    1.17 +            new ClearMethodStateTest(test).runTest();
    1.18 +        }
    1.19      }
    1.20  
    1.21 +    public ClearMethodStateTest(TestCase testCase) {
    1.22 +        super(testCase);
    1.23 +        // to prevent inlining of #method
    1.24 +        WHITE_BOX.testSetDontInlineMethod(method, true);
    1.25 +    }
    1.26 +
    1.27 +
    1.28 +    /**
    1.29 +     * Tests {@code WB::clearMethodState()} by calling it before/after
    1.30 +     * compilation. For non-tiered, checks that counters will be rested after
    1.31 +     * clearing of method state.
    1.32 +     *
    1.33 +     * @throws Exception if one of the checks fails.
    1.34 +     */
    1.35 +    @Override
    1.36      protected void test() throws Exception {
    1.37 -        checkNotCompiled(METHOD);
    1.38 +        checkNotCompiled();
    1.39          compile();
    1.40 -        checkCompiled(METHOD);
    1.41 -        WHITE_BOX.clearMethodState(METHOD);
    1.42 -        WHITE_BOX.deoptimizeMethod(METHOD);
    1.43 -        checkNotCompiled(METHOD);
    1.44 +        WHITE_BOX.clearMethodState(method);
    1.45 +        checkCompiled();
    1.46 +        WHITE_BOX.clearMethodState(method);
    1.47 +        WHITE_BOX.deoptimizeMethod(method);
    1.48 +        checkNotCompiled();
    1.49  
    1.50  
    1.51          if (!TIERED_COMPILATION) {
    1.52 -            WHITE_BOX.clearMethodState(METHOD);
    1.53 +            WHITE_BOX.clearMethodState(method);
    1.54              compile(COMPILE_THRESHOLD);
    1.55 -            checkCompiled(METHOD);
    1.56 +            checkCompiled();
    1.57  
    1.58 -            WHITE_BOX.deoptimizeMethod(METHOD);
    1.59 -            checkNotCompiled(METHOD);
    1.60 -            WHITE_BOX.clearMethodState(METHOD);
    1.61 +            WHITE_BOX.deoptimizeMethod(method);
    1.62 +            checkNotCompiled();
    1.63 +            WHITE_BOX.clearMethodState(method);
    1.64  
    1.65 +            // invoke method one less time than needed to compile
    1.66              if (COMPILE_THRESHOLD > 1) {
    1.67                  compile(COMPILE_THRESHOLD - 1);
    1.68 -                checkNotCompiled(METHOD);
    1.69 +                checkNotCompiled();
    1.70              } else {
    1.71 -               System.err.println("Warning: 'CompileThreshold' <= 1");
    1.72 +                System.err.println("Warning: 'CompileThreshold' <= 1");
    1.73              }
    1.74  
    1.75 -            method();
    1.76 -            checkCompiled(METHOD);
    1.77 +            compile(1);
    1.78 +            checkCompiled();
    1.79          } else {
    1.80              System.err.println(
    1.81                      "Warning: part of test is not applicable in Tiered");

mercurial