--- old/test/gc/arguments/TestMaxHeapSizeTools.java 2013-11-19 15:52:33.000000000 -0800 +++ new/test/gc/arguments/TestMaxHeapSizeTools.java 2013-11-19 15:52:33.000000000 -0800 @@ -25,6 +25,8 @@ import java.util.regex.Pattern; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.List; import com.oracle.java.testlibrary.*; import sun.hotspot.WhiteBox; @@ -41,8 +43,8 @@ public long initialHeapSize; public long maxHeapSize; - public long minAlignment; - public long maxAlignment; + public long spaceAlignment; + public long heapAlignment; } class TestMaxHeapSizeTools { @@ -181,19 +183,26 @@ return output; } - private static void getMinInitialMaxHeap(String[] args, MinInitialMaxValues val) throws Exception { - OutputAnalyzer output = runWhiteBoxTest(args, ErgoArgsPrinter.class.getName(), new String[] {}, false); + private static void getMinInitialMaxHeap(String[] args, MinInitialMaxValues val, Boolean[] parallelGC) throws Exception { + List argsList = new ArrayList<>(); + Collections.addAll(argsList, args); + Collections.addAll(argsList, "-XX:+PrintFlagsFinal"); + + OutputAnalyzer output = runWhiteBoxTest(argsList.toArray(new String[0]), ErgoArgsPrinter.class.getName(), new String[0], false); + String stdOut = output.getStdout(); + + parallelGC[0] = FlagsValue.getFlagBoolValue(stdOut, "UseParallelGC"); // the output we watch for has the following format: // - // "Minimum heap X Initial heap Y Maximum heap Z Min alignment A Max Alignment B" + // "Minimum heap X Initial heap Y Maximum heap Z Space alignment A Heap alignment B" // // where A, B, X, Y and Z are sizes in bytes. // Unfortunately there is no other way to retrieve the minimum heap size and // the alignments. - - Matcher m = Pattern.compile("Minimum heap \\d+ Initial heap \\d+ Maximum heap \\d+ Min alignment \\d+ Max alignment \\d+"). - matcher(output.getStdout()); + Matcher m = Pattern. + compile("Minimum heap \\d+ Initial heap \\d+ Maximum heap \\d+ Space alignment \\d+ Heap alignment \\d+"). + matcher(stdOut); if (!m.find()) { throw new RuntimeException("Could not find heap size string."); } @@ -204,8 +213,8 @@ val.minHeapSize = valueAfter(match, "Minimum heap "); val.initialHeapSize = valueAfter(match, "Initial heap "); val.maxHeapSize = valueAfter(match, "Maximum heap "); - val.minAlignment = valueAfter(match, "Min alignment "); - val.maxAlignment = valueAfter(match, "Max alignment "); + val.spaceAlignment = valueAfter(match, "Space alignment "); + val.heapAlignment = valueAfter(match, "Heap alignment "); } /** @@ -216,14 +225,14 @@ long expectedMin, long expectedInitial) throws Exception { MinInitialMaxValues v = new MinInitialMaxValues(); - getMinInitialMaxHeap(args, v); + getMinInitialMaxHeap(args, v, new Boolean[1]); - if ((expectedMin != -1) && (align_up(expectedMin, v.minAlignment) != v.minHeapSize)) { + if ((expectedMin != -1) && (align_up(expectedMin, v.spaceAlignment) != v.minHeapSize)) { throw new RuntimeException("Actual minimum heap size of " + v.minHeapSize + " differs from expected minimum heap size of " + expectedMin); } - if ((expectedInitial != -1) && (align_up(expectedInitial, v.minAlignment) != v.initialHeapSize)) { + if ((expectedInitial != -1) && (align_up(expectedInitial, v.spaceAlignment) != v.initialHeapSize)) { throw new RuntimeException("Actual initial heap size of " + v.initialHeapSize + " differs from expected initial heap size of " + expectedInitial); } @@ -245,10 +254,16 @@ final long K = 1024; MinInitialMaxValues v = new MinInitialMaxValues(); - getMinInitialMaxHeap(new String[] { gcflag, "-XX:MaxHeapSize=" + maxHeapsize + "M" }, v); + Boolean[] parallelGC = new Boolean[1]; + getMinInitialMaxHeap(new String[] { gcflag, "-XX:MaxHeapSize=" + maxHeapsize + "M" }, v, parallelGC); - long expectedHeapSize = align_up(maxHeapsize * K * K, v.maxAlignment); long actualHeapSize = v.maxHeapSize; + long expectedHeapSize = align_up(maxHeapsize * K * K, v.heapAlignment); + if (parallelGC[0] == true) { + // numberOfSpaces is for tenured space, eden space, from space and to space + int numberOfSpaces = 4; + expectedHeapSize = Math.max(expectedHeapSize, numberOfSpaces * v.spaceAlignment); + } if (actualHeapSize > expectedHeapSize) { throw new RuntimeException("Heap has " + actualHeapSize +