Merge
authordfazunen
Thu, 21 Jul 2016 16:45:56 +0000
changeset 39994 df6091cda80a
parent 39992 358e93ea57df (current diff)
parent 39993 82256382f7a1 (diff)
child 39995 c4787ceda7a8
child 39997 a65e14a0d827
Merge
--- a/hotspot/test/gc/TestSmallHeap.java	Thu Jul 21 16:29:21 2016 +0200
+++ b/hotspot/test/gc/TestSmallHeap.java	Thu Jul 21 16:45:56 2016 +0000
@@ -34,7 +34,7 @@
  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestSmallHeap
  */
 
-/* Note: It would be nice to verify the minimal supported heap size (2m) here,
+/* Note: It would be nice to verify the minimal supported heap size here,
  * but we align the heap size based on the card table size. And the card table
  * size is aligned based on the minimal pages size provided by the os. This
  * means that on most platforms, where the minimal page size is 4k, we get a
@@ -43,14 +43,18 @@
  * we get a minimal heap size of 32m. We never use large pages for the card table.
  *
  * There is also no check in the VM for verifying that the maximum heap size
- * is larger than the supported minimal heap size. This means that specifying
- * -Xmx1m on the command line is fine but will give a heap of 2m (or 4m or 32m).
+ * is larger than the supported minimal heap size.
  *
- * To work around these rather strange behaviors this test uses -Xmx2m but then
+ * To work around these behaviors this test uses -Xmx4m but then
  * calculates what the expected heap size should be. The calculation is a
  * simplified version of the code in the VM. We assume that the card table will
  * use one page. Each byte in the card table corresponds to 512 bytes on the heap.
  * So, the expected heap size is page_size * 512.
+ *
+ * There is no formal requirement for the minimal value of the maximum heap size
+ * the VM should support. In most cases the VM could start with -Xmx2m.
+ * But with 2m limit GC could be triggered before VM initialization completed.
+ * Therefore we start the VM with 4M heap.
  */
 
 import jdk.test.lib.Asserts;
@@ -79,9 +83,10 @@
     }
 
     private static void verifySmallHeapSize(String gc, long expectedMaxHeap) throws Exception {
+        long minMaxHeap = 4 * 1024 * 1024;
         LinkedList<String> vmOptions = new LinkedList<>();
         vmOptions.add(gc);
-        vmOptions.add("-Xmx2m");
+        vmOptions.add("-Xmx" + minMaxHeap);
         vmOptions.add("-XX:+PrintFlagsFinal");
         vmOptions.add(VerifyHeapSize.class.getName());
 
@@ -89,6 +94,7 @@
         OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
         analyzer.shouldHaveExitValue(0);
 
+        expectedMaxHeap = Math.max(expectedMaxHeap, minMaxHeap);
         long maxHeapSize = Long.parseLong(analyzer.firstMatch("MaxHeapSize.+=\\s+(\\d+)",1));
         long actualHeapSize = Long.parseLong(analyzer.firstMatch(VerifyHeapSize.actualMsg + "(\\d+)",1));
         Asserts.assertEQ(maxHeapSize, expectedMaxHeap);
--- a/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Thu Jul 21 16:29:21 2016 +0200
+++ b/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Thu Jul 21 16:45:56 2016 +0000
@@ -106,7 +106,6 @@
   }
 
   public static void checkGenMaxHeapErgo(String gcflag) throws Exception {
-    TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 3);
     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 4);
     TestMaxHeapSizeTools.checkGenMaxHeapSize(gcflag, 5);
   }
@@ -132,7 +131,6 @@
   }
 
   private static void checkValidInitialMaxHeapCombinations(String gcflag) throws Exception {
-    expectValid(new String[] { gcflag, "-XX:MaxHeapSize=2048K", "-version" });
     expectValid(new String[] { gcflag, "-XX:InitialHeapSize=4M", "-XX:MaxHeapSize=8M", "-version" });
     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=8M", "-XX:InitialHeapSize=4M", "-version" });
     expectValid(new String[] { gcflag, "-XX:MaxHeapSize=4M", "-XX:InitialHeapSize=4M", "-version" });