8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
authorthartmann
Fri, 24 Oct 2014 08:27:39 +0200
changeset 27418 a13fdcbaa345
parent 27417 576e2b527e1c
child 27419 a934f24b4dcf
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build Summary: Added check for product build and compute minimum code cache size accordingly. Reviewed-by: kvn, iignatyev
hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java
--- a/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java	Fri Oct 24 08:22:33 2014 +0200
+++ b/hotspot/test/compiler/codecache/CheckSegmentedCodeCache.java	Fri Oct 24 08:27:39 2014 +0200
@@ -22,15 +22,20 @@
  */
 
 import com.oracle.java.testlibrary.*;
+import sun.hotspot.WhiteBox;
 
 /*
  * @test CheckSegmentedCodeCache
  * @bug 8015774
+ * @library /testlibrary /testlibrary/whitebox
  * @summary "Checks VM options related to the segmented code cache"
- * @library /testlibrary
- * @run main/othervm CheckSegmentedCodeCache
+ * @build CheckSegmentedCodeCache
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CheckSegmentedCodeCache
  */
 public class CheckSegmentedCodeCache {
+  private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
   // Code heap names
   private static final String NON_METHOD = "CodeHeap 'non-nmethods'";
   private static final String PROFILED = "CodeHeap 'profiled nmethods'";
@@ -133,8 +138,12 @@
     failsWith(pb, "Invalid code heap sizes");
 
     // Fails if not enough space for VM internal code
+    long minUseSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumUseSpace");
+    long minFreeSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumFreeSpace");
+    // minimum size: (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace
+    long minSize = (Platform.isDebugBuild() ? 3 : 1) * minUseSpace + minFreeSpace;
     pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache",
-                                               "-XX:ReservedCodeCacheSize=1700K",
+                                               "-XX:ReservedCodeCacheSize=" + minSize,
                                                "-XX:InitialCodeCacheSize=100K");
     failsWith(pb, "Not enough space in non-nmethod code heap to run VM");
   }