diff test/compiler/whitebox/IsMethodCompilableTest.java @ 10113:4b2eebe03f93

8011971: WB API doesn't accept j.l.reflect.Constructor Reviewed-by: kvn, vlivanov
author iignatyev
date Tue, 16 Apr 2013 10:04:01 -0700
parents b84fd7d73702
children 11237ee74aae
line wrap: on
line diff
--- a/test/compiler/whitebox/IsMethodCompilableTest.java	Tue Apr 16 10:37:16 2013 -0400
+++ b/test/compiler/whitebox/IsMethodCompilableTest.java	Tue Apr 16 10:04:01 2013 -0700
@@ -28,9 +28,13 @@
  * @build IsMethodCompilableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IsMethodCompilableTest
+ * @summary testing of WB::isMethodCompilable()
  * @author igor.ignatyev@oracle.com
  */
 public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
+    /**
+     * Value of {@code -XX:PerMethodRecompilationCutoff}
+     */
     protected static final long PER_METHOD_RECOMPILATION_CUTOFF;
 
     static {
@@ -44,14 +48,28 @@
     }
 
     public static void main(String[] args) throws Exception {
-        // to prevent inlining #method into #compile()
-        WHITE_BOX.testSetDontInlineMethod(METHOD, true);
-        new IsMethodCompilableTest().runTest();
+        for (TestCase test : TestCase.values()) {
+            new IsMethodCompilableTest(test).runTest();
+        }
+    }
+
+    public IsMethodCompilableTest(TestCase testCase) {
+        super(testCase);
+        // to prevent inlining of #method
+        WHITE_BOX.testSetDontInlineMethod(method, true);
     }
 
+    /**
+     * Tests {@code WB::isMethodCompilable()} by recompilation of tested method
+     * 'PerMethodRecompilationCutoff' times and checks compilation status. Also
+     * checks that WB::clearMethodState() clears no-compilable flags.
+     *
+     * @throws Exception if one of the checks fails.
+     */
+    @Override
     protected void test() throws Exception {
-        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
-            throw new RuntimeException(METHOD + " must be compilable");
+        if (!WHITE_BOX.isMethodCompilable(method)) {
+            throw new RuntimeException(method + " must be compilable");
         }
         System.out.println("PerMethodRecompilationCutoff = "
                 + PER_METHOD_RECOMPILATION_CUTOFF);
@@ -61,46 +79,47 @@
             return;
         }
 
-        // deoptimze 'PerMethodRecompilationCutoff' times and clear state
+        // deoptimize 'PerMethodRecompilationCutoff' times and clear state
         for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
-            compileAndDeoptimaze();
+            compileAndDeoptimize();
         }
-        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
-            throw new RuntimeException(METHOD + " is not compilable after "
+        if (!WHITE_BOX.isMethodCompilable(method)) {
+            throw new RuntimeException(method + " is not compilable after "
                     + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
         }
-        WHITE_BOX.clearMethodState(METHOD);
+        WHITE_BOX.clearMethodState(method);
 
-        // deoptimze 'PerMethodRecompilationCutoff' + 1 times
+        // deoptimize 'PerMethodRecompilationCutoff' + 1 times
         long i;
         for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
-                && WHITE_BOX.isMethodCompilable(METHOD); ++i) {
-            compileAndDeoptimaze();
+                && WHITE_BOX.isMethodCompilable(method); ++i) {
+            compileAndDeoptimize();
         }
         if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
-           throw new RuntimeException(METHOD + " is not compilable after "
-                   + i + " iterations, but must only after "
-                   + PER_METHOD_RECOMPILATION_CUTOFF);
+            throw new RuntimeException(method + " is not compilable after "
+                    + i + " iterations, but must only after "
+                    + PER_METHOD_RECOMPILATION_CUTOFF);
         }
-        if (WHITE_BOX.isMethodCompilable(METHOD)) {
-            throw new RuntimeException(METHOD + " is still compilable after "
+        if (WHITE_BOX.isMethodCompilable(method)) {
+            throw new RuntimeException(method + " is still compilable after "
                     + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
         }
         compile();
-        checkNotCompiled(METHOD);
+        checkNotCompiled();
 
-        WHITE_BOX.clearMethodState(METHOD);
-        if (!WHITE_BOX.isMethodCompilable(METHOD)) {
-            throw new RuntimeException(METHOD
-                    + " is compilable after clearMethodState()");
+        // WB.clearMethodState() must reset no-compilable flags
+        WHITE_BOX.clearMethodState(method);
+        if (!WHITE_BOX.isMethodCompilable(method)) {
+            throw new RuntimeException(method
+                    + " is not compilable after clearMethodState()");
         }
         compile();
-        checkCompiled(METHOD);
+        checkCompiled();
     }
 
-    private void compileAndDeoptimaze() throws Exception {
+    private void compileAndDeoptimize() throws Exception {
         compile();
-        waitBackgroundCompilation(METHOD);
-        WHITE_BOX.deoptimizeMethod(METHOD);
+        waitBackgroundCompilation();
+        WHITE_BOX.deoptimizeMethod(method);
     }
 }