changeset 11690:6ab8be269224

8153194: PreserveFPRegistersTest.java runs out of memory in the nightlies. Summary: Fixed test by setting reference size using WhileBox.getHeapOopSize. Reviewed-by: vlivanov
author rraghavan
date Thu, 30 Jun 2016 05:05:52 -0700
parents fa25a40620af
children 22d70546af81
files test/compiler/gcbarriers/PreserveFPRegistersTest.java
diffstat 1 files changed, 30 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/compiler/gcbarriers/PreserveFPRegistersTest.java	Tue May 24 01:13:57 2016 -0700
+++ b/test/compiler/gcbarriers/PreserveFPRegistersTest.java	Thu Jun 30 05:05:52 2016 -0700
@@ -25,15 +25,22 @@
 /**
  * @test
  * @bug 8148175
- * @ignore 8153194
- * @run main/othervm/timeout=300 -Xbatch -Xmx128m PreserveFPRegistersTest
+ * @requires vm.gc=="G1" | vm.gc=="null"
+ * @library /testlibrary /test/lib
+ * @run main/bootclasspath/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions
+ *      -XX:+WhiteBoxAPI -Xmx300m -XX:+UseG1GC PreserveFPRegistersTest
  */
+
+import sun.hotspot.WhiteBox;
+
 public class PreserveFPRegistersTest {
 
     public static void main(String... args) throws InterruptedException {
         new PreserveFPRegistersTest().go();
     }
 
+    private static WhiteBox wb = WhiteBox.getWhiteBox();
+
     public final Object[][] storage;
 
     /**
@@ -52,18 +59,32 @@
     public final int regionCount;
 
     PreserveFPRegistersTest() {
-        long regionSize = 1_000_000; //WB.g1RegionSize();
-
+        long regionSize = wb.g1RegionSize();
         Runtime rt = Runtime.getRuntime();
         long used = rt.totalMemory() - rt.freeMemory();
         long totalFree = rt.maxMemory() - used;
         regionCount = (int) ( (totalFree / regionSize) * 0.9);
-        int refSize = 4;
+        int refSize = wb.getHeapOopSize();
+        N = (int) ((regionSize / K ) / refSize) - 5;
 
-        N = (int) ((regionSize / K ) / refSize) - 5;
-        storage = new Object[regionCount * K][];
-        for (int i = 0; i < storage.length; i++) {
-            storage[i] = new Object[N];
+        System.out.println("%% Memory");
+        System.out.println("%%   used          :        " + used / 1024 + "M");
+        System.out.println("%%   available     :        " + totalFree / 1024 + "M");
+        System.out.println("%%   G1 Region Size:        " + regionSize / 1024 + "M");
+        System.out.println("%%   region count  :        " + regionCount);
+
+        System.out.println("%% Objects storage");
+        System.out.println("%%   N (array length)      : " + N);
+        System.out.println("%%   K (objects in regions): " + K);
+        System.out.println("%%   Reference size        : " + refSize);
+
+        try {
+            storage = new Object[regionCount * K][];
+            for (int i = 0; i < storage.length; i++) {
+                storage[i] = new Object[N];
+            }
+        } catch(OutOfMemoryError e) {
+            throw new AssertionError("Test Failed with unexpected OutOfMemoryError exception");
         }
     }