--- old/src/share/vm/prims/whitebox.cpp 2013-11-15 18:37:49.000000000 -0800 +++ new/src/share/vm/prims/whitebox.cpp 2013-11-15 18:37:48.000000000 -0800 @@ -104,8 +104,8 @@ WB_ENTRY(void, WB_PrintHeapSizes(JNIEnv* env, jobject o)) { CollectorPolicy * p = Universe::heap()->collector_policy(); - gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap " - SIZE_FORMAT" Maximum heap "SIZE_FORMAT" Min alignment "SIZE_FORMAT" Max alignment "SIZE_FORMAT, + gclog_or_tty->print_cr("Minimum heap "SIZE_FORMAT" Initial heap "SIZE_FORMAT" Maximum heap "SIZE_FORMAT + " Space alignment "SIZE_FORMAT" Heap alignment "SIZE_FORMAT, p->min_heap_byte_size(), p->initial_heap_byte_size(), p->max_heap_byte_size(), p->space_alignment(), p->heap_alignment()); } --- old/test/gc/arguments/TestMaxHeapSizeTools.java 2013-11-15 18:37:49.000000000 -0800 +++ new/test/gc/arguments/TestMaxHeapSizeTools.java 2013-11-15 18:37:49.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,15 @@ 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) { + int numberOfSpaces = 4; + expectedHeapSize = Math.max(expectedHeapSize, numberOfSpaces * v.spaceAlignment); + } if (actualHeapSize > expectedHeapSize) { throw new RuntimeException("Heap has " + actualHeapSize + --- old/test/gc/arguments/TestParallelHeapSizeFlags.java 2013-11-15 18:37:50.000000000 -0800 +++ new/test/gc/arguments/TestParallelHeapSizeFlags.java 2013-11-15 18:37:49.000000000 -0800 @@ -28,7 +28,7 @@ * @summary Tests argument processing for initial and maximum heap size for the * parallel collectors. * @library /testlibrary /testlibrary/whitebox - * @build TestParallelHeapSizeFlags TestMaxHeapSizeTools + * @build TestParallelHeapSizeFlags TestMaxHeapSizeTools FlagsValue * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm TestParallelHeapSizeFlags * @author thomas.schatzl@oracle.com --- /dev/null 2013-11-15 18:37:50.000000000 -0800 +++ new/test/gc/arguments/FlagsValue.java 2013-11-15 18:37:50.000000000 -0800 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +*/ + +import java.util.regex.*; + +public class FlagsValue { + public static boolean getFlagBoolValue(String where, String flag) { + Matcher m = Pattern.compile(flag + "\\s+:?= (true|false)").matcher(where); + if (!m.find()) { + throw new RuntimeException("Could not find value for flag " + flag + " in output string"); + } + return m.group(1).equals("true"); + } + + public static long getFlagLongValue(String where, String flag) { + Matcher m = Pattern.compile(flag + "\\s+:?=\\s+\\d+").matcher(where); + if (!m.find()) { + throw new RuntimeException("Could not find value for flag " + flag + " in output string"); + } + String match = m.group(); + return Long.parseLong(match.substring(match.lastIndexOf(" ") + 1, match.length())); + } +} \ No newline at end of file