8067941: [TESTBUG] Fix tests for OS with 64K page size.
authorgoetz
Mon, 12 Jan 2015 14:43:34 -0800
changeset 28497 a7aecf0ffb6b
parent 28496 f9753412d4f5
child 28502 16b69673f35c
8067941: [TESTBUG] Fix tests for OS with 64K page size. Reviewed-by: kvn, tschatzl, ctornqvi
hotspot/src/share/vm/memory/metaspace.cpp
hotspot/test/compiler/exceptions/TestRecursiveReplacedException.java
hotspot/test/compiler/runtime/6865265/StackOverflowBug.java
hotspot/test/compiler/uncommontrap/8009761/Test8009761.java
hotspot/test/compiler/uncommontrap/StackOverflowGuardPagesOff.java
hotspot/test/compiler/uncommontrap/TestStackBangMonitorOwned.java
hotspot/test/compiler/uncommontrap/TestStackBangRbp.java
hotspot/test/gc/arguments/TestMaxHeapSizeTools.java
hotspot/test/gc/g1/TestGCLogMessages.java
hotspot/test/gc/g1/TestHumongousAllocInitialMark.java
hotspot/test/runtime/whitebox/WBStackSize.java
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Mon Jan 12 14:43:34 2015 -0800
@@ -3829,11 +3829,13 @@
       assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up");
     }
 
-    { // 4 pages of VSN is committed, some is used by chunks
+    const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
+    // This doesn't work for systems with vm_page_size >= 16K.
+    if (page_chunks < MediumChunk) {
+      // 4 pages of VSN is committed, some is used by chunks
       ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk);
       VirtualSpaceNode vsn(vsn_test_size_bytes);
-      const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
-      assert(page_chunks < MediumChunk, "Test expects medium chunks to be at least 4*page_size");
+
       vsn.initialize();
       vsn.expand_by(page_chunks, page_chunks);
       vsn.get_chunk_vs(SmallChunk);
--- a/hotspot/test/compiler/exceptions/TestRecursiveReplacedException.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/exceptions/TestRecursiveReplacedException.java	Mon Jan 12 14:43:34 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8054224
  * @summary Recursive method compiled by C1 is unable to catch StackOverflowError
- * @run main/othervm -Xcomp -XX:CompileOnly=Test.run -XX:+TieredCompilation -XX:TieredStopAtLevel=2 -Xss256K TestRecursiveReplacedException
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test.run -XX:+TieredCompilation -XX:TieredStopAtLevel=2 -Xss392K TestRecursiveReplacedException
  *
  */
 
--- a/hotspot/test/compiler/runtime/6865265/StackOverflowBug.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/runtime/6865265/StackOverflowBug.java	Mon Jan 12 14:43:34 2015 -0800
@@ -28,7 +28,7 @@
  * @summary JVM crashes with "missing exception handler" error
  * @author volker.simonis@sap.com
  *
- * @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss248k StackOverflowBug
+ * @run main/othervm -XX:CompileThreshold=100 -Xbatch -Xss392k StackOverflowBug
  */
 
 
--- a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java	Mon Jan 12 14:43:34 2015 -0800
@@ -32,7 +32,7 @@
  * @build Test8009761
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss392K Test8009761
  */
 public class Test8009761 {
 
--- a/hotspot/test/compiler/uncommontrap/StackOverflowGuardPagesOff.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/uncommontrap/StackOverflowGuardPagesOff.java	Mon Jan 12 14:43:34 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8029383
  * @summary stack overflow if callee is marked for deoptimization causes crash
- * @run main/othervm -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,StackOverflowGuardPagesOff::m1 -XX:CompileCommand=exclude,StackOverflowGuardPagesOff::m2 -Xss256K -XX:-UseOnStackReplacement StackOverflowGuardPagesOff
+ * @run main/othervm -XX:TieredStopAtLevel=1 -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,StackOverflowGuardPagesOff::m1 -XX:CompileCommand=exclude,StackOverflowGuardPagesOff::m2 -Xss392K -XX:-UseOnStackReplacement StackOverflowGuardPagesOff
  *
  */
 
--- a/hotspot/test/compiler/uncommontrap/TestStackBangMonitorOwned.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/uncommontrap/TestStackBangMonitorOwned.java	Mon Jan 12 14:43:34 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8032410
  * @summary Stack overflow at deoptimization doesn't release owned monitors
- * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss392K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
  *
  */
 public class TestStackBangMonitorOwned {
--- a/hotspot/test/compiler/uncommontrap/TestStackBangRbp.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/compiler/uncommontrap/TestStackBangRbp.java	Mon Jan 12 14:43:34 2015 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 8028308
  * @summary rbp not restored when stack overflow is thrown from deopt/uncommon trap blobs
- * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangRbp::m1 -XX:CompileCommand=exclude,TestStackBangRbp::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangRbp
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangRbp::m1 -XX:CompileCommand=exclude,TestStackBangRbp::m2 -Xss392K -XX:-UseOnStackReplacement TestStackBangRbp
  *
  */
 public class TestStackBangRbp {
--- a/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/gc/arguments/TestMaxHeapSizeTools.java	Mon Jan 12 14:43:34 2015 -0800
@@ -112,7 +112,7 @@
   }
 
   private static void checkInvalidMinInitialHeapCombinations(String gcflag) throws Exception {
-    expectError(new String[] { gcflag, "-Xms8M", "-XX:InitialHeapSize=4M", "-version" });
+    expectError(new String[] { gcflag, "-Xms64M", "-XX:InitialHeapSize=32M", "-version" });
   }
 
   private static void checkValidMinInitialHeapCombinations(String gcflag) throws Exception {
--- a/hotspot/test/gc/g1/TestGCLogMessages.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/gc/g1/TestGCLogMessages.java	Mon Jan 12 14:43:34 2015 -0800
@@ -107,8 +107,8 @@
 
   private static void testWithToSpaceExhaustionLogs() throws Exception {
     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
-                                               "-Xmx10M",
-                                               "-Xmn5M",
+                                               "-Xmx32M",
+                                               "-Xmn16M",
                                                "-XX:+PrintGCDetails",
                                                GCTestWithToSpaceExhaustion.class.getName());
 
@@ -120,8 +120,8 @@
     output.shouldHaveExitValue(0);
 
     pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
-                                               "-Xmx10M",
-                                               "-Xmn5M",
+                                               "-Xmx32M",
+                                               "-Xmn16M",
                                                "-XX:+PrintGCDetails",
                                                "-XX:+UnlockExperimentalVMOptions",
                                                "-XX:G1LogLevel=finest",
@@ -151,7 +151,7 @@
     private static byte[] garbage;
     private static byte[] largeObject;
     public static void main(String [] args) {
-      largeObject = new byte[5*1024*1024];
+      largeObject = new byte[16*1024*1024];
       System.out.println("Creating garbage");
       // create 128MB of garbage. This should result in at least one GC,
       // some of them with to-space exhaustion.
--- a/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/gc/g1/TestHumongousAllocInitialMark.java	Mon Jan 12 14:43:34 2015 -0800
@@ -31,7 +31,9 @@
 import com.oracle.java.testlibrary.*;
 
 public class TestHumongousAllocInitialMark {
-    private static final int heapSize                       = 200; // MB
+    // Heap sizes < 224 MB are increased to 224 MB if vm_page_size == 64K to
+    // fulfill alignment constraints.
+    private static final int heapSize                       = 224; // MB
     private static final int heapRegionSize                 = 1;   // MB
     private static final int initiatingHeapOccupancyPercent = 50;  // %
 
--- a/hotspot/test/runtime/whitebox/WBStackSize.java	Tue Jan 13 12:30:26 2015 +0100
+++ b/hotspot/test/runtime/whitebox/WBStackSize.java	Mon Jan 12 14:43:34 2015 -0800
@@ -47,7 +47,7 @@
     static final long K = 1024;
 
     static final long MIN_STACK_SIZE = 8 * K;
-    static final long MAX_STACK_SIZE_ALLOCATED_IN_MAIN = 200 * K; // current value is about 130k on 64-bit platforms
+    static final long MAX_STACK_SIZE_ALLOCATED_IN_MAIN = 150 * K; // current value is about 130k on 64-bit platforms
 
     static final WhiteBox wb = WhiteBox.getWhiteBox();
 
@@ -82,8 +82,10 @@
 
     public static void main(String[] args) {
         long configStackSize = wb.getIntxVMFlag("ThreadStackSize") * K;
+        System.out.println("ThreadStackSize VM option: " + configStackSize);
 
-        System.out.println("ThreadStackSize VM option: " + configStackSize);
+        long stackProtectionSize = wb.getIntxVMFlag("StackShadowPages") * wb.getVMPageSize();
+        System.out.println("Size of protected shadow pages: " + stackProtectionSize);
 
         long actualStackSize = wb.getThreadStackSize();
         System.out.println("Full stack size: " + actualStackSize);
@@ -96,14 +98,16 @@
         long remainingStackSize = wb.getThreadRemainingStackSize();
         System.out.println("Remaining stack size in main(): " + remainingStackSize);
 
-        // Up to 200k can be already allocated by VM
+        // Up to 150k can be already allocated by VM and some space is used for stack protection.
+        long spaceAlreadyOccupied = MAX_STACK_SIZE_ALLOCATED_IN_MAIN + stackProtectionSize;
+
         if (remainingStackSize > configStackSize
-                || (configStackSize > MAX_STACK_SIZE_ALLOCATED_IN_MAIN
-                && remainingStackSize < configStackSize - MAX_STACK_SIZE_ALLOCATED_IN_MAIN)) {
+            || (configStackSize > spaceAlreadyOccupied
+                && remainingStackSize < configStackSize - spaceAlreadyOccupied)) {
 
             throw new RuntimeException("getThreadRemainingStackSize value [" + remainingStackSize
                                      + "] should be at least ThreadStackSize value [" + configStackSize + "] minus ["
-                                     + MAX_STACK_SIZE_ALLOCATED_IN_MAIN + "]");
+                                     + spaceAlreadyOccupied + "]");
         }
 
         testStackOverflow();