Merge
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 711f4e8..e8826de 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -353,3 +353,4 @@
e1c506c8e1db7356d120dd7d22b2c50276b6bcee jdk8u40-b17
83d1d42c3df409c87ef7cb0126343a009857ca71 jdk8u40-b18
ae4980d195b64eec58884b233d7efd312205bac8 jdk8u40-b19
+b31a07adaef50dacba20e376cff6f1096e745092 jdk8u40-b20
diff --git a/corba/.hgtags b/corba/.hgtags
index 3c0e8ba..b61bbd4 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -351,3 +351,4 @@
bff1a326ac97c543b9c271adebc9deeda974edb1 jdk8u40-b17
a1e2c13de84e00f2aedf4c40e96347306ede84f3 jdk8u40-b18
8bbc2bb414b7e9331c2014c230553d72c9d161c5 jdk8u40-b19
+445eceffc829e205037098115c26e38e85ea5f7c jdk8u40-b20
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 6db374a..eb5a29e 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -563,3 +563,5 @@
31d3306aad29e39929418ed43f28212a5f5306a3 jdk8u40-b18
f8fc5cbe082ce0fb0c6c1dcd39493a16ed916353 hs25.40-b23
d9349fa8822336e0244da0a8448f3e6b2d62741d jdk8u40-b19
+c3933f52eeb33f70ee562464edddfe9f01d944fd jdk8u40-b20
+d2e9a6bec4f2eec8506eed16f7324992a85d8480 hs25.40-b24
diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version
index ebdd5c3..fbfe5ae 100644
--- a/hotspot/make/hotspot_version
+++ b/hotspot/make/hotspot_version
@@ -35,7 +35,7 @@
HS_MAJOR_VER=25
HS_MINOR_VER=40
-HS_BUILD_NUMBER=23
+HS_BUILD_NUMBER=24
JDK_MAJOR_VER=1
JDK_MINOR_VER=8
diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups
index 5a17031..339ff38 100644
--- a/hotspot/test/TEST.groups
+++ b/hotspot/test/TEST.groups
@@ -171,6 +171,7 @@
gc/g1/TestShrinkAuxiliaryData20.java \
gc/g1/TestShrinkAuxiliaryData25.java \
gc/g1/TestShrinkAuxiliaryData30.java \
+ gc/survivorAlignment \
runtime/InternalApi/ThreadCpuTimesDeadlock.java \
serviceability/threads/TestFalseDeadLock.java \
serviceability/jvmti/GetObjectSizeOverflow.java \
diff --git a/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java b/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java
new file mode 100644
index 0000000..125faed
--- /dev/null
+++ b/hotspot/test/gc/arguments/TestSurvivorAlignmentInBytesOption.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2014, 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 com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify SurvivorAlignmentInBytes option processing.
+ * @library /testlibrary
+ * @requires vm.opt.SurvivorAlignmentInBytes == null
+ * & vm.opt.ObjectAlignmentInBytes == null
+ * & vm.opt.UnlockExperimentalVMOptions == null
+ * & (vm.opt.IgnoreUnrecognizedVMOptions == null
+ * | vm.opt.IgnoreUnrecognizedVMOptions == "false")
+ * @run main TestSurvivorAlignmentInBytesOption
+ */
+public class TestSurvivorAlignmentInBytesOption {
+ public static void main(String args[]) throws Throwable {
+ String optionName = "SurvivorAlignmentInBytes";
+ String unlockExperimentalVMOpts = "UnlockExperimentalVMOptions";
+ String optionIsExperimental
+ = CommandLineOptionTest.getExperimentalOptionErrorMessage(
+ optionName);
+ String valueIsTooSmall= ".*SurvivorAlignmentInBytes=.*must be greater"
+ + " than ObjectAlignmentInBytes.*";
+ String mustBePowerOf2 = ".*SurvivorAlignmentInBytes=.*must be "
+ + "power of 2.*";
+
+ // Verify that without -XX:+UnlockExperimentalVMOptions usage of
+ // SurvivorAlignmentInBytes option will cause JVM startup failure
+ // with the warning message saying that that option is experimental.
+ CommandLineOptionTest.verifyJVMStartup(
+ new String[]{optionIsExperimental}, null, ExitCode.FAIL, false,
+ "-XX:-UnlockExperimentalVMOptions",
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, false),
+ CommandLineOptionTest.prepareNumericFlag(optionName, 64));
+
+ // Verify that with -XX:+UnlockExperimentalVMOptions passed to JVM
+ // usage of SurvivorAlignmentInBytes option won't cause JVM startup
+ // failure.
+ CommandLineOptionTest.verifyJVMStartup(
+ null, new String[]{optionIsExperimental}, ExitCode.OK, false,
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, true),
+ CommandLineOptionTest.prepareNumericFlag(optionName, 64));
+
+ // Verify that if specified SurvivorAlignmentInBytes is lower then
+ // ObjectAlignmentInBytes, then the JVM startup will fail with
+ // appropriate error message.
+ CommandLineOptionTest.verifyJVMStartup(
+ new String[]{valueIsTooSmall}, null, ExitCode.FAIL, false,
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, true),
+ CommandLineOptionTest.prepareNumericFlag(optionName, 2));
+
+ // Verify that if specified SurvivorAlignmentInBytes value is not
+ // a power of 2 then the JVM startup will fail with appropriate error
+ // message.
+ CommandLineOptionTest.verifyJVMStartup(
+ new String[]{mustBePowerOf2}, null, ExitCode.FAIL, false,
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, true),
+ CommandLineOptionTest.prepareNumericFlag(optionName, 127));
+
+ // Verify that if SurvivorAlignmentInBytes has correct value, then
+ // the JVM will be started without errors.
+ CommandLineOptionTest.verifyJVMStartup(
+ null, new String[]{".*SurvivorAlignmentInBytes.*"},
+ ExitCode.OK, false,
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, true),
+ CommandLineOptionTest.prepareNumericFlag(optionName, 128));
+
+ // Verify that we can setup different SurvivorAlignmentInBytes values.
+ for (int alignment = 32; alignment <= 128; alignment *= 2) {
+ CommandLineOptionTest.verifyOptionValue(optionName,
+ Integer.toString(alignment),
+ CommandLineOptionTest.prepareBooleanFlag(
+ unlockExperimentalVMOpts, true),
+ CommandLineOptionTest.prepareNumericFlag(
+ optionName, alignment));
+ }
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/AlignmentHelper.java b/hotspot/test/gc/survivorAlignment/AlignmentHelper.java
new file mode 100644
index 0000000..57de213
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/AlignmentHelper.java
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2014, 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.lang.management.MemoryPoolMXBean;
+import java.util.Optional;
+
+import sun.hotspot.WhiteBox;
+
+/**
+ * Helper class aimed to provide information about alignment of objects in
+ * particular heap space, expected memory usage after objects' allocation so on.
+ */
+public class AlignmentHelper {
+ private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+ private static final long OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM = 8L;
+
+ /**
+ * Max relative allowed actual memory usage deviation from expected memory
+ * usage.
+ */
+ private static final float MAX_RELATIVE_DEVIATION = 0.05f; // 5%
+
+ public static final long OBJECT_ALIGNMENT_IN_BYTES = Optional.ofNullable(
+ AlignmentHelper.WHITE_BOX.getIntxVMFlag("ObjectAlignmentInBytes"))
+ .orElse(AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES_FOR_32_VM);
+
+ public static final long SURVIVOR_ALIGNMENT_IN_BYTES = Optional.ofNullable(
+ AlignmentHelper.WHITE_BOX.getIntxVMFlag("SurvivorAlignmentInBytes"))
+ .orElseThrow(() ->new AssertionError(
+ "Unable to get SurvivorAlignmentInBytes value"));
+ /**
+ * Min amount of memory that will be occupied by an object.
+ */
+ public static final long MIN_OBJECT_SIZE
+ = AlignmentHelper.WHITE_BOX.getObjectSize(new Object());
+ /**
+ * Min amount of memory that will be occupied by an empty byte array.
+ */
+ public static final long MIN_ARRAY_SIZE
+ = AlignmentHelper.WHITE_BOX.getObjectSize(new byte[0]);
+
+ /**
+ * Precision at which actual memory usage in a heap space represented by
+ * this sizing helper could be measured.
+ */
+ private final long memoryUsageMeasurementPrecision;
+ /**
+ * Min amount of memory that will be occupied by an object allocated in a
+ * heap space represented by this sizing helper.
+ */
+ private final long minObjectSizeInThisSpace;
+ /**
+ * Object's alignment in a heap space represented by this sizing helper.
+ */
+ private final long objectAlignmentInThisRegion;
+ /**
+ * MemoryPoolMXBean associated with a heap space represented by this sizing
+ * helper.
+ */
+ private final MemoryPoolMXBean poolMXBean;
+
+ private static long alignUp(long value, long alignment) {
+ return ((value - 1) / alignment + 1) * alignment;
+ }
+
+ protected AlignmentHelper(long memoryUsageMeasurementPrecision,
+ long objectAlignmentInThisRegion, long minObjectSizeInThisSpace,
+ MemoryPoolMXBean poolMXBean) {
+ this.memoryUsageMeasurementPrecision = memoryUsageMeasurementPrecision;
+ this.minObjectSizeInThisSpace = minObjectSizeInThisSpace;
+ this.objectAlignmentInThisRegion = objectAlignmentInThisRegion;
+ this.poolMXBean = poolMXBean;
+ }
+
+ /**
+ * Returns how many objects have to be allocated to fill
+ * {@code memoryToFill} bytes in this heap space using objects of size
+ * {@code objectSize}.
+ */
+ public int getObjectsCount(long memoryToFill, long objectSize) {
+ return (int) (memoryToFill / getObjectSizeInThisSpace(objectSize));
+ }
+
+ /**
+ * Returns amount of memory that {@code objectsCount} of objects with size
+ * {@code objectSize} will occupy this this space after allocation.
+ */
+ public long getExpectedMemoryUsage(long objectSize, int objectsCount) {
+ long correctedObjectSize = getObjectSizeInThisSpace(objectSize);
+ return AlignmentHelper.alignUp(correctedObjectSize * objectsCount,
+ memoryUsageMeasurementPrecision);
+ }
+
+ /**
+ * Returns current memory usage in this heap space.
+ */
+ public long getActualMemoryUsage() {
+ return poolMXBean.getUsage().getUsed();
+ }
+
+ /**
+ * Returns maximum memory usage deviation from {@code expectedMemoryUsage}
+ * given the max allowed relative deviation equal to
+ * {@code relativeDeviation}.
+ *
+ * Note that value returned by this method is aligned according to
+ * memory measurement precision for this heap space.
+ */
+ public long getAllowedMemoryUsageDeviation(long expectedMemoryUsage) {
+ long unalignedDeviation = (long) (expectedMemoryUsage *
+ AlignmentHelper.MAX_RELATIVE_DEVIATION);
+ return AlignmentHelper.alignUp(unalignedDeviation,
+ memoryUsageMeasurementPrecision);
+ }
+
+ /**
+ * Returns amount of memory that will be occupied by an object with size
+ * {@code objectSize} in this heap space.
+ */
+ public long getObjectSizeInThisSpace(long objectSize) {
+ objectSize = Math.max(objectSize, minObjectSizeInThisSpace);
+
+ long alignedObjectSize = AlignmentHelper.alignUp(objectSize,
+ objectAlignmentInThisRegion);
+ long sizeDiff = alignedObjectSize - objectSize;
+
+ // If there is not enough space to fit padding object, then object will
+ // be aligned to {@code 2 * objectAlignmentInThisRegion}.
+ if (sizeDiff >= AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES
+ && sizeDiff < AlignmentHelper.MIN_OBJECT_SIZE) {
+ alignedObjectSize += AlignmentHelper.MIN_OBJECT_SIZE;
+ alignedObjectSize = AlignmentHelper.alignUp(alignedObjectSize,
+ objectAlignmentInThisRegion);
+ }
+
+ return alignedObjectSize;
+ }
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append(String.format("AlignmentHelper for memory pool '%s':%n",
+ poolMXBean.getName()));
+ builder.append(String.format("Memory usage measurement precision: %d%n",
+ memoryUsageMeasurementPrecision));
+ builder.append(String.format("Min object size in this space: %d%n",
+ minObjectSizeInThisSpace));
+ builder.append(String.format("Object alignment in this space: %d%n",
+ objectAlignmentInThisRegion));
+
+ return builder.toString();
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java
new file mode 100644
index 0000000..77de614
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2014, 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.lang.management.ManagementFactory;
+import java.lang.management.MemoryPoolMXBean;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.oracle.java.testlibrary.Asserts;
+import com.sun.management.ThreadMXBean;
+import sun.hotspot.WhiteBox;
+import sun.misc.Unsafe;
+
+/**
+ * Main class for tests on {@code SurvivorAlignmentInBytes} option.
+ *
+ * Typical usage is to obtain instance using fromArgs method, allocate objects
+ * and verify that actual memory usage in tested heap space is close to
+ * expected.
+ */
+public class SurvivorAlignmentTestMain {
+ enum HeapSpace {
+ EDEN,
+ SURVIVOR,
+ TENURED
+ }
+
+ public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+ public static final long MAX_TENURING_THRESHOLD = Optional.ofNullable(
+ SurvivorAlignmentTestMain.WHITE_BOX.getIntxVMFlag(
+ "MaxTenuringThreshold")).orElse(15L);
+
+ /**
+ * Regexp used to parse memory size params, like 2G, 34m or 15k.
+ */
+ private static final Pattern SIZE_REGEX
+ = Pattern.compile("(?<size>[0-9]+)(?<multiplier>[GMKgmk])?");
+
+ // Names of different heap spaces.
+ private static final String DEF_NEW_EDEN = "Eden Space";
+ private static final String DEF_NEW_SURVIVOR = "Survivor Space";
+ private static final String PAR_NEW_EDEN = "Par Eden Space";
+ private static final String PAR_NEW_SURVIVOR = "Par Survivor Space";
+ private static final String PS_EDEN = "PS Eden Space";
+ private static final String PS_SURVIVOR = "PS Survivor Space";
+ private static final String G1_EDEN = "G1 Eden Space";
+ private static final String G1_SURVIVOR = "G1 Survivor Space";
+ private static final String SERIAL_TENURED = "Tenured Gen";
+ private static final String CMS_TENURED = "CMS Old Gen";
+ private static final String PS_TENURED = "PS Old Gen";
+ private static final String G1_TENURED = "G1 Old Gen";
+
+ private static final long G1_HEAP_REGION_SIZE = Optional.ofNullable(
+ SurvivorAlignmentTestMain.WHITE_BOX.getUintxVMFlag(
+ "G1HeapRegionSize")).orElse(-1L);
+
+ /**
+ * Min size of free chunk in CMS generation.
+ * An object allocated in CMS generation will at least occupy this amount
+ * of bytes.
+ */
+ private static final long CMS_MIN_FREE_CHUNK_SIZE
+ = 3L * Unsafe.ADDRESS_SIZE;
+
+ private static final AlignmentHelper EDEN_SPACE_HELPER;
+ private static final AlignmentHelper SURVIVOR_SPACE_HELPER;
+ private static final AlignmentHelper TENURED_SPACE_HELPER;
+ /**
+ * Amount of memory that should be filled during a test run.
+ */
+ private final long memoryToFill;
+ /**
+ * The size of an objects that will be allocated during a test run.
+ */
+ private final long objectSize;
+ /**
+ * Amount of memory that will be actually occupied by an object in eden
+ * space.
+ */
+ private final long actualObjectSize;
+ /**
+ * Storage for allocated objects.
+ */
+ private final Object[] garbage;
+ /**
+ * Heap space whose memory usage is a subject of assertions during the test
+ * run.
+ */
+ private final HeapSpace testedSpace;
+
+ private long[] baselinedThreadMemoryUsage = null;
+ private long[] threadIds = null;
+
+ /**
+ * Initialize {@code EDEN_SPACE_HELPER}, {@code SURVIVOR_SPACE_HELPER} and
+ * {@code TENURED_SPACE_HELPER} to represent heap spaces in use.
+ *
+ * Note that regardless to GC object's alignment in survivor space is
+ * expected to be equal to {@code SurvivorAlignmentInBytes} value and
+ * alignment in other spaces is expected to be equal to
+ * {@code ObjectAlignmentInBytes} value.
+ *
+ * In CMS generation we can't allocate less then {@code MinFreeChunk} value,
+ * for other CGs we expect that object of size {@code MIN_OBJECT_SIZE}
+ * could be allocated as it is (of course, its size could be aligned
+ * according to alignment value used in a particular space).
+ *
+ * For G1 GC MXBeans could report memory usage only with region size
+ * precision (if an object allocated in some G1 heap region, then all region
+ * will claimed as used), so for G1's spaces precision is equal to
+ * {@code G1HeapRegionSize} value.
+ */
+ static {
+ AlignmentHelper edenHelper = null;
+ AlignmentHelper survivorHelper = null;
+ AlignmentHelper tenuredHelper = null;
+ for (MemoryPoolMXBean pool : ManagementFactory.getMemoryPoolMXBeans()) {
+ switch (pool.getName()) {
+ case SurvivorAlignmentTestMain.DEF_NEW_EDEN:
+ case SurvivorAlignmentTestMain.PAR_NEW_EDEN:
+ case SurvivorAlignmentTestMain.PS_EDEN:
+ Asserts.assertNull(edenHelper,
+ "Only one bean for eden space is expected.");
+ edenHelper = new AlignmentHelper(
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.MIN_OBJECT_SIZE, pool);
+ break;
+ case SurvivorAlignmentTestMain.G1_EDEN:
+ Asserts.assertNull(edenHelper,
+ "Only one bean for eden space is expected.");
+ edenHelper = new AlignmentHelper(
+ SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.MIN_OBJECT_SIZE, pool);
+ break;
+ case SurvivorAlignmentTestMain.DEF_NEW_SURVIVOR:
+ case SurvivorAlignmentTestMain.PAR_NEW_SURVIVOR:
+ case SurvivorAlignmentTestMain.PS_SURVIVOR:
+ Asserts.assertNull(survivorHelper,
+ "Only one bean for survivor space is expected.");
+ survivorHelper = new AlignmentHelper(
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.MIN_OBJECT_SIZE, pool);
+ break;
+ case SurvivorAlignmentTestMain.G1_SURVIVOR:
+ Asserts.assertNull(survivorHelper,
+ "Only one bean for survivor space is expected.");
+ survivorHelper = new AlignmentHelper(
+ SurvivorAlignmentTestMain.G1_HEAP_REGION_SIZE,
+ AlignmentHelper.SURVIVOR_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.MIN_OBJECT_SIZE, pool);
+ break;
+ case SurvivorAlignmentTestMain.SERIAL_TENURED:
+ case SurvivorAlignmentTestMain.PS_TENURED:
+ case SurvivorAlignmentTestMain.G1_TENURED:
+ Asserts.assertNull(tenuredHelper,
+ "Only one bean for tenured space is expected.");
+ tenuredHelper = new AlignmentHelper(
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.MIN_OBJECT_SIZE, pool);
+ break;
+ case SurvivorAlignmentTestMain.CMS_TENURED:
+ Asserts.assertNull(tenuredHelper,
+ "Only one bean for tenured space is expected.");
+ tenuredHelper = new AlignmentHelper(
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ AlignmentHelper.OBJECT_ALIGNMENT_IN_BYTES,
+ SurvivorAlignmentTestMain.CMS_MIN_FREE_CHUNK_SIZE,
+ pool);
+ break;
+ }
+ }
+ EDEN_SPACE_HELPER = Objects.requireNonNull(edenHelper,
+ "AlignmentHelper for eden space should be initialized.");
+ SURVIVOR_SPACE_HELPER = Objects.requireNonNull(survivorHelper,
+ "AlignmentHelper for survivor space should be initialized.");
+ TENURED_SPACE_HELPER = Objects.requireNonNull(tenuredHelper,
+ "AlignmentHelper for tenured space should be initialized.");
+ }
+ /**
+ * Returns an SurvivorAlignmentTestMain instance constructed using CLI
+ * options.
+ *
+ * Following options are expected:
+ * <ul>
+ * <li>memoryToFill</li>
+ * <li>objectSize</li>
+ * </ul>
+ *
+ * Both argument may contain multiplier suffix k, m or g.
+ */
+ public static SurvivorAlignmentTestMain fromArgs(String[] args) {
+ Asserts.assertEQ(args.length, 3, "Expected three arguments: "
+ + "memory size, object size and tested heap space name.");
+
+ long memoryToFill = parseSize(args[0]);
+ long objectSize = Math.max(parseSize(args[1]),
+ AlignmentHelper.MIN_ARRAY_SIZE);
+ HeapSpace testedSpace = HeapSpace.valueOf(args[2]);
+
+ return new SurvivorAlignmentTestMain(memoryToFill, objectSize,
+ testedSpace);
+ }
+
+ /**
+ * Returns a value parsed from a string with format
+ * <integer><multiplier>.
+ */
+ private static long parseSize(String sizeString) {
+ Matcher matcher = SIZE_REGEX.matcher(sizeString);
+ Asserts.assertTrue(matcher.matches(),
+ "sizeString should have following format \"[0-9]+([MBK])?\"");
+ long size = Long.valueOf(matcher.group("size"));
+
+ if (matcher.group("multiplier") != null) {
+ long K = 1024L;
+ // fall through multipliers
+ switch (matcher.group("multiplier").toLowerCase()) {
+ case "g":
+ size *= K;
+ case "m":
+ size *= K;
+ case "k":
+ size *= K;
+ }
+ }
+ return size;
+ }
+
+ private SurvivorAlignmentTestMain(long memoryToFill, long objectSize,
+ HeapSpace testedSpace) {
+ this.objectSize = objectSize;
+ this.memoryToFill = memoryToFill;
+ this.testedSpace = testedSpace;
+
+ AlignmentHelper helper = SurvivorAlignmentTestMain.EDEN_SPACE_HELPER;
+
+ this.actualObjectSize = helper.getObjectSizeInThisSpace(
+ this.objectSize);
+ int arrayLength = helper.getObjectsCount(memoryToFill, this.objectSize);
+ garbage = new Object[arrayLength];
+ }
+
+ /**
+ * Allocate byte arrays to fill {@code memoryToFill} memory.
+ */
+ public void allocate() {
+ int byteArrayLength = Math.max((int) (objectSize
+ - Unsafe.ARRAY_BYTE_BASE_OFFSET), 0);
+
+ for (int i = 0; i < garbage.length; i++) {
+ garbage[i] = new byte[byteArrayLength];
+ }
+ }
+
+ /**
+ * Release memory occupied after {@code allocate} call.
+ */
+ public void release() {
+ for (int i = 0; i < garbage.length; i++) {
+ garbage[i] = null;
+ }
+ }
+
+ /**
+ * Returns expected amount of memory occupied in a {@code heapSpace} by
+ * objects referenced from {@code garbage} array.
+ */
+ public long getExpectedMemoryUsage() {
+ AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);
+ return alignmentHelper.getExpectedMemoryUsage(objectSize,
+ garbage.length);
+ }
+
+ /**
+ * Verifies that memory usage in a {@code heapSpace} deviates from
+ * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
+ */
+ public void verifyMemoryUsage(long expectedUsage) {
+ AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);
+
+ long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
+ boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();
+
+ long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
+ long maxAllowedUsageDiff
+ = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);
+
+ System.out.println("Verifying memory usage in space: " + testedSpace);
+ System.out.println("Allocated objects count: " + garbage.length);
+ System.out.println("Desired object size: " + objectSize);
+ System.out.println("Actual object size: " + actualObjectSize);
+ System.out.println("Expected object size in space: "
+ + alignmentHelper.getObjectSizeInThisSpace(objectSize));
+ System.out.println("Expected memory usage: " + expectedUsage);
+ System.out.println("Actual memory usage: " + actualMemoryUsage);
+ System.out.println("Memory usage diff: " + memoryUsageDiff);
+ System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);
+
+ if (memoryUsageDiff > maxAllowedUsageDiff
+ && otherThreadsAllocatedMemory) {
+ System.out.println("Memory usage diff is incorrect, but it seems "
+ + "like someone else allocated objects");
+ return;
+ }
+
+ Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
+ "Actual memory usage should not deviate from expected for " +
+ "more then " + maxAllowedUsageDiff);
+ }
+
+ /**
+ * Baselines amount of memory allocated by each thread.
+ */
+ public void baselineMemoryAllocation() {
+ ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
+ threadIds = bean.getAllThreadIds();
+ baselinedThreadMemoryUsage = bean.getThreadAllocatedBytes(threadIds);
+ }
+
+ /**
+ * Checks if threads other then the current thread were allocating objects
+ * after baselinedThreadMemoryUsage call.
+ *
+ * If baselinedThreadMemoryUsage was not called, then this method will return
+ * {@code false}.
+ */
+ public boolean areOtherThreadsAllocatedMemory() {
+ if (baselinedThreadMemoryUsage == null) {
+ return false;
+ }
+
+ ThreadMXBean bean = (ThreadMXBean) ManagementFactory.getThreadMXBean();
+ long currentMemoryAllocation[]
+ = bean.getThreadAllocatedBytes(threadIds);
+ boolean otherThreadsAllocatedMemory = false;
+
+ System.out.println("Verifying amount of memory allocated by threads:");
+ for (int i = 0; i < threadIds.length; i++) {
+ System.out.format("Thread %d%nbaseline allocation: %d"
+ + "%ncurrent allocation:%d%n", threadIds[i],
+ baselinedThreadMemoryUsage[i], currentMemoryAllocation[i]);
+ System.out.println(bean.getThreadInfo(threadIds[i]));
+
+ long bytesAllocated = Math.abs(currentMemoryAllocation[i]
+ - baselinedThreadMemoryUsage[i]);
+ if (bytesAllocated > 0
+ && threadIds[i] != Thread.currentThread().getId()) {
+ otherThreadsAllocatedMemory = true;
+ }
+ }
+
+ return otherThreadsAllocatedMemory;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append(String.format("SurvivorAlignmentTestMain info:%n"));
+ builder.append(String.format("Desired object size: %d%n", objectSize));
+ builder.append(String.format("Memory to fill: %d%n", memoryToFill));
+ builder.append(String.format("Objects to be allocated: %d%n",
+ garbage.length));
+
+ builder.append(String.format("Alignment helpers to be used: %n"));
+ for (HeapSpace heapSpace: HeapSpace.values()) {
+ builder.append(String.format("For space %s:%n%s%n", heapSpace,
+ getAlignmentHelper(heapSpace)));
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Returns {@code AlignmentHelper} for a space {@code heapSpace}.
+ */
+ public static AlignmentHelper getAlignmentHelper(HeapSpace heapSpace) {
+ switch (heapSpace) {
+ case EDEN:
+ return SurvivorAlignmentTestMain.EDEN_SPACE_HELPER;
+ case SURVIVOR:
+ return SurvivorAlignmentTestMain.SURVIVOR_SPACE_HELPER;
+ case TENURED:
+ return SurvivorAlignmentTestMain.TENURED_SPACE_HELPER;
+ default:
+ throw new Error("Unexpected heap space: " + heapSpace);
+ }
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java b/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java
new file mode 100644
index 0000000..3191451
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/TestAllocationInEden.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify that object's alignment in eden space is not affected by
+ * SurvivorAlignmentInBytes option.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestAllocationInEden SurvivorAlignmentTestMain AlignmentHelper
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 9 EDEN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 47 EDEN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 9 EDEN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 87 EDEN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 9 EDEN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128 -XX:-UseTLAB
+ * -XX:OldSize=128m -XX:MaxHeapSize=192m
+ * -XX:-ExplicitGCInvokesConcurrent
+ * TestAllocationInEden 10m 147 EDEN
+ */
+public class TestAllocationInEden {
+ public static void main(String args[]) {
+ SurvivorAlignmentTestMain test
+ = SurvivorAlignmentTestMain.fromArgs(args);
+ System.out.println(test);
+
+ long expectedMemoryUsage = test.getExpectedMemoryUsage();
+ test.baselineMemoryAllocation();
+ System.gc();
+
+ test.allocate();
+
+ test.verifyMemoryUsage(expectedMemoryUsage);
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java b/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java
new file mode 100644
index 0000000..5c58ffb
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromEdenToTenured.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify that objects promoted from eden space to tenured space during
+ * full GC are not aligned to SurvivorAlignmentInBytes value.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestPromotionFromEdenToTenured SurvivorAlignmentTestMain
+ * AlignmentHelper
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromEdenToTenured 10m 9 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromEdenToTenured 10m 47 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32m -XX:MaxHeapSize=96m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromEdenToTenured 10m 9 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32m -XX:MaxHeapSize=128m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromEdenToTenured 10m 87 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32M -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromEdenToTenured 10m 9 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=64m -XX:MaxNewSize=64m
+ * -XX:OldSize=32m -XX:MaxHeapSize=96m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromEdenToTenured 10m 147 TENURED
+ */
+public class TestPromotionFromEdenToTenured {
+ public static void main(String args[]) {
+ SurvivorAlignmentTestMain test
+ = SurvivorAlignmentTestMain.fromArgs(args);
+ System.out.println(test);
+
+ long expectedMemoryUsage = test.getExpectedMemoryUsage();
+ test.baselineMemoryAllocation();
+ System.gc();
+ // increase expected usage by current old gen usage
+ expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
+ SurvivorAlignmentTestMain.HeapSpace.TENURED)
+ .getActualMemoryUsage();
+
+ test.allocate();
+ System.gc();
+
+ test.verifyMemoryUsage(expectedMemoryUsage);
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java
new file mode 100644
index 0000000..d89adc6
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify that objects promoted from survivor space to tenured space
+ * during full GC are not aligned to SurvivorAlignmentInBytes value.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestPromotionFromSurvivorToTenuredAfterFullGC
+ * SurvivorAlignmentTestMain AlignmentHelper
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32m -XX:MaxHeapSize=160m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32m -XX:MaxHeapSize=160m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 20m 47
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
+ * -XX:OldSize=32m -XX:MaxHeapSize=232m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32m -XX:MaxHeapSize=160m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 20m 87
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
+ * -XX:OldSize=32M -XX:MaxHeapSize=288m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32m -XX:MaxHeapSize=160m
+ * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromSurvivorToTenuredAfterFullGC 20m 147
+ * TENURED
+ */
+public class TestPromotionFromSurvivorToTenuredAfterFullGC {
+ public static void main(String args[]) {
+ SurvivorAlignmentTestMain test
+ = SurvivorAlignmentTestMain.fromArgs(args);
+ System.out.println(test);
+
+ long expectedMemoryUsage = test.getExpectedMemoryUsage();
+ test.baselineMemoryAllocation();
+ System.gc();
+ // increase expected usage by current old gen usage
+ expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
+ SurvivorAlignmentTestMain.HeapSpace.TENURED)
+ .getActualMemoryUsage();
+
+ test.allocate();
+ SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
+ System.gc();
+
+ test.verifyMemoryUsage(expectedMemoryUsage);
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java
new file mode 100644
index 0000000..7c3176f
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify that objects promoted from survivor space to tenured space
+ * when their age exceeded tenuring threshold are not aligned to
+ * SurvivorAlignmentInBytes value.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestPromotionFromSurvivorToTenuredAfterMinorGC
+ * SurvivorAlignmentTestMain AlignmentHelper
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 47
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m
+ * -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 87
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
+ * -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9
+ * TENURED
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=1
+ * -XX:-ExplicitGCInvokesConcurrent
+ * -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128
+ * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 147
+ * TENURED
+ */
+public class TestPromotionFromSurvivorToTenuredAfterMinorGC {
+ public static void main(String args[]) throws Exception {
+ SurvivorAlignmentTestMain test
+ = SurvivorAlignmentTestMain.fromArgs(args);
+ System.out.println(test);
+
+ long expectedMemoryUsage = test.getExpectedMemoryUsage();
+ test.baselineMemoryAllocation();
+ SurvivorAlignmentTestMain.WHITE_BOX.fullGC();
+ // increase expected usage by current old gen usage
+ expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(
+ SurvivorAlignmentTestMain.HeapSpace.TENURED)
+ .getActualMemoryUsage();
+
+ test.allocate();
+ for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD;
+ i++) {
+ SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
+ }
+
+ test.verifyMemoryUsage(expectedMemoryUsage);
+ }
+}
diff --git a/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java b/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java
new file mode 100644
index 0000000..e6a1d1c
--- /dev/null
+++ b/hotspot/test/gc/survivorAlignment/TestPromotionToSurvivor.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2014, 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.
+ */
+
+/**
+ * @test
+ * @bug 8031323
+ * @summary Verify that objects promoted from eden space to survivor space after
+ * minor GC are aligned to SurvivorAlignmentInBytes.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestPromotionToSurvivor
+ * SurvivorAlignmentTestMain AlignmentHelper
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
+ * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 10m 9 SURVIVOR
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m
+ * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 20m 47 SURVIVOR
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
+ * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 8m 9 SURVIVOR
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m
+ * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 20m 87 SURVIVOR
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
+ * -XX:MaxHeapSize=384m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 10m 9 SURVIVOR
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m
+ * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions
+ * -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m
+ * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent
+ * TestPromotionToSurvivor 20m 147 SURVIVOR
+ */
+public class TestPromotionToSurvivor {
+ public static void main(String args[]) {
+ SurvivorAlignmentTestMain test
+ = SurvivorAlignmentTestMain.fromArgs(args);
+ System.out.println(test);
+
+ long expectedUsage = test.getExpectedMemoryUsage();
+ test.baselineMemoryAllocation();
+ SurvivorAlignmentTestMain.WHITE_BOX.fullGC();
+
+ test.allocate();
+ SurvivorAlignmentTestMain.WHITE_BOX.youngGC();
+
+ test.verifyMemoryUsage(expectedUsage);
+ }
+}
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 43cf770a..e0504d4 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -353,3 +353,4 @@
cb63029168a52d62d82c3325f1092405c318e78c jdk8u40-b17
6103f5a8119a85937ae006f18b8dfc04f73315d0 jdk8u40-b18
3b73732d6886dc8155f0c1fbb125ca60d9e2fd2b jdk8u40-b19
+7bfc889330e0ec1fd495990eaa0d7f0c390b7304 jdk8u40-b20
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 3d16840..0c621ca 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -351,3 +351,4 @@
83c4d5aca2ff8fd0c6b2a7091018b71313371176 jdk8u40-b17
fa07311627d085f1307f55298f59463bcf55db02 jdk8u40-b18
c8b402c28fe51e25f3298e1266f2ae48bda8d3e0 jdk8u40-b19
+a21c4edfdf4402f027183ac8c8aac2db49df3b7d jdk8u40-b20
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 7a2da96..df6ec4a 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -354,3 +354,4 @@
fc4f5546417071c70cffd89ca83302309f6f7da9 jdk8u40-b17
20a3e2135e0867e55af72f0c66a3de558bc613e2 jdk8u40-b18
5c31204d19e5976f025026db3d5c17331e8c44db jdk8u40-b19
+7784dab075ed82be2275f4694164bbb9cc1cde3f jdk8u40-b20
diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk
index 9515279..844cccd 100644
--- a/make/Javadoc.gmk
+++ b/make/Javadoc.gmk
@@ -1116,14 +1116,15 @@
NASHORNAPI_HEADER := <strong>Nashorn API</strong>
NASHORNAPI_BOTTOM := $(call CommonBottom,$(NASHORNAPI_FIRST_COPYRIGHT_YEAR))
NASHORNAPI_GROUPNAME := Packages
-NASHORNAPI_REGEXP := com.sun.source.*
+NASHORNAPI_REGEXP := jdk.nashorn.api.scripting.*
+
# NASHORNAPI_PKGS is located in NON_CORE_PKGS.gmk
NASHORNAPI_INDEX_HTML = $(NASHORNAPI_DOCDIR)/index.html
-NASHORNAPI_OPTIONS_FILE = $(DOCSTMPDIR)/treeapi.options
-NASHORNAPI_PACKAGES_FILE = $(DOCSTMPDIR)/treeapi.packages
+NASHORNAPI_OPTIONS_FILE = $(DOCSTMPDIR)/nashornapi.options
+NASHORNAPI_PACKAGES_FILE = $(DOCSTMPDIR)/nashornapi.packages
-treeapidocs: $(NASHORNAPI_INDEX_HTML)
+nashornapidocs: $(NASHORNAPI_INDEX_HTML)
# Set relative location to core api document root
$(NASHORNAPI_INDEX_HTML): GET2DOCSDIR=$(NASHORNAPI2COREAPI)/..
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index 9d0b6b3..37e1f08 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -339,3 +339,4 @@
88e22262fdb26e3154a1034c2413415e97b9a86a jdk8u40-b17
653739706172ae94e999731a3a9f10f8ce11ffca jdk8u40-b18
6ec61d2494283fbaca6df227f1a5b45487dc1ca7 jdk8u40-b19
+4d240320929f7b2247eeb97e43efe2370b70582e jdk8u40-b20