8048003: test/compiler/8009761/Test8009761.java failed with: java.lang.RuntimeException: static java.lang.Object Test8009761.m3(boolean,boolean) not compiled
authorthartmann
Mon, 30 Jun 2014 08:28:29 +0200
changeset 25377 73d03d578d8e
parent 25365 6db782823853
child 25378 d9eeb53578f9
8048003: test/compiler/8009761/Test8009761.java failed with: java.lang.RuntimeException: static java.lang.Object Test8009761.m3(boolean,boolean) not compiled Summary: Compile m3 with C1 if C2 is not available. Reviewed-by: twisti, anoll
hotspot/test/compiler/8009761/Test8009761.java
--- a/hotspot/test/compiler/8009761/Test8009761.java	Thu Jun 26 18:55:29 2014 -0700
+++ b/hotspot/test/compiler/8009761/Test8009761.java	Mon Jun 30 08:28:29 2014 +0200
@@ -21,11 +21,7 @@
  * questions.
  */
 
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
 import sun.hotspot.WhiteBox;
-import sun.management.ManagementFactoryHelper;
-
 import java.lang.reflect.Method;
 
 /*
@@ -40,6 +36,7 @@
 public class Test8009761 {
 
     private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+    private static int COMP_LEVEL_SIMPLE = 1;
     private static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
     private static Method m3 = null;
 
@@ -236,7 +233,7 @@
 
     static public void main(String[] args) {
         // Make sure background compilation is disabled
-        if (backgroundCompilationEnabled()) {
+        if (WHITE_BOX.getBooleanVMFlag("BackgroundCompilation")) {
             throw new RuntimeException("Background compilation enabled");
         }
 
@@ -256,7 +253,11 @@
         c1 = count;
 
         // Force the compilation of m3() that will inline m1()
-        WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION);
+        if(!WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION)) {
+            // C2 compiler not available, compile with C1
+            WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_SIMPLE);
+        }
+
         // Because background compilation is disabled, method should now be compiled
         if(!WHITE_BOX.isMethodCompiled(m3)) {
             throw new RuntimeException(m3 + " not compiled");
@@ -278,19 +279,4 @@
             System.out.println("PASSED " + c1);
         }
     }
-
-    /**
-     * Checks if background compilation (-XX:+BackgroundCompilation) is enabled.
-     * @return True if background compilation is enabled, false otherwise
-     */
-    private static boolean backgroundCompilationEnabled() {
-      HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
-      VMOption backgroundCompilation;
-      try {
-          backgroundCompilation = diagnostic.getVMOption("BackgroundCompilation");
-      } catch (IllegalArgumentException e) {
-          return false;
-      }
-      return Boolean.valueOf(backgroundCompilation.getValue());
-    }
 }