diff test/compiler/whitebox/IsMethodCompilableTest.java @ 14726:92aa6797d639

Backed out merge changeset: b51e29501f30 Backed out merge revision to its first parent (8f483e200405)
author Doug Simon <doug.simon@oracle.com>
date Mon, 24 Mar 2014 21:30:43 +0100
parents 2dfa56e10640
children
line wrap: on
line diff
--- a/test/compiler/whitebox/IsMethodCompilableTest.java	Fri Mar 21 16:36:59 2014 -0700
+++ b/test/compiler/whitebox/IsMethodCompilableTest.java	Mon Mar 24 21:30:43 2014 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,17 +24,13 @@
 /*
  * @test IsMethodCompilableTest
  * @bug 8007270 8006683 8007288 8022832
- * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary
+ * @library /testlibrary /testlibrary/whitebox
  * @build IsMethodCompilableTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
- * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform
- * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest
+ * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest
  * @summary testing of WB::isMethodCompilable()
  * @author igor.ignatyev@oracle.com
  */
-
-import com.oracle.java.testlibrary.Platform;
-
 public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
     /**
      * Value of {@code -XX:PerMethodRecompilationCutoff}
@@ -47,7 +43,7 @@
         if (tmp == -1) {
             PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */;
         } else {
-            PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp);
+            PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp);
         }
     }
 
@@ -64,23 +60,19 @@
     /**
      * Tests {@code WB::isMethodCompilable()} by recompilation of tested method
      * 'PerMethodRecompilationCutoff' times and checks compilation status. Also
-     * checks that WB::clearMethodState() clears no-compilable flags. Only
-     * applicable to c2 compiled methods.
+     * checks that WB::clearMethodState() clears no-compilable flags.
      *
      * @throws Exception if one of the checks fails.
      */
     @Override
     protected void test() throws Exception {
-
-        // Only c2 compilations can be disabled through PerMethodRecompilationCutoff
-        if (!Platform.isServer()) {
-            return;
+        if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith(
+                "compiled ")) {
+          System.err.printf("Warning: %s is not applicable in %s%n",
+                testCase.name(), CompilerWhiteBoxTest.MODE);
+          return;
         }
-
-        if (skipXcompOSR()) {
-            return;
-        }
-        if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
+        if (!isCompilable()) {
             throw new RuntimeException(method + " must be compilable");
         }
         System.out.println("PerMethodRecompilationCutoff = "
@@ -91,37 +83,39 @@
             return;
         }
 
-        // deoptimize 'PerMethodRecompilationCutoff' times
-        for (long attempts = 0, successes = 0;
-               (successes < PER_METHOD_RECOMPILATION_CUTOFF)  &&
-               (attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) &&
-               isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) {
-            if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) {
-                successes++;
-            }
+        // deoptimize 'PerMethodRecompilationCutoff' times and clear state
+        for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
+            compileAndDeoptimize();
         }
-
-        if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
+        if (!testCase.isOsr() && !isCompilable()) {
             // in osr test case count of deopt maybe more than iterations
             throw new RuntimeException(method + " is not compilable after "
-                    + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
+                    + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
         }
+        WHITE_BOX.clearMethodState(method);
 
-        // Now compile once more
-        compileAndDeoptimize();
-
-        if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
+        // deoptimize 'PerMethodRecompilationCutoff' + 1 times
+        long i;
+        for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
+                && isCompilable(); ++i) {
+            compileAndDeoptimize();
+        }
+        if (!testCase.isOsr() && i != PER_METHOD_RECOMPILATION_CUTOFF) {
+            // in osr test case count of deopt maybe more than iterations
+            throw new RuntimeException(method + " is not compilable after "
+                    + i + " iterations, but must only after "
+                    + PER_METHOD_RECOMPILATION_CUTOFF);
+        }
+        if (isCompilable()) {
             throw new RuntimeException(method + " is still compilable after "
                     + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
         }
+        compile();
         checkNotCompiled();
-        compile();
-        waitBackgroundCompilation();
-        checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION);
 
         // WB.clearMethodState() must reset no-compilable flags
         WHITE_BOX.clearMethodState(method);
-        if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) {
+        if (!isCompilable()) {
             throw new RuntimeException(method
                     + " is not compilable after clearMethodState()");
         }
@@ -129,11 +123,9 @@
         checkCompiled();
     }
 
-    private int compileAndDeoptimize() throws Exception {
+    private void compileAndDeoptimize() throws Exception {
         compile();
         waitBackgroundCompilation();
-        int compLevel = getCompLevel();
         deoptimize();
-        return compLevel;
     }
 }