1 /* 2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /** 25 * @test 26 * @bug 8031323 27 * @summary Verify that objects promoted from eden space to survivor space after 28 * minor GC are aligned to SurvivorAlignmentInBytes. 29 * @library /testlibrary /../../test/lib 30 * @modules java.base/sun.misc 31 * java.management 32 * @build TestPromotionToSurvivor 33 * SurvivorAlignmentTestMain AlignmentHelper 34 * @ignore 8129886 35 * @run main ClassFileInstaller sun.hotspot.WhiteBox 36 * sun.hotspot.WhiteBox$WhiteBoxPermission 37 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 38 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 39 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 40 * -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m 41 * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 42 * TestPromotionToSurvivor 10m 9 SURVIVOR 43 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 44 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 45 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 46 * -XX:SurvivorAlignmentInBytes=32 -XX:OldSize=128m 47 * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 48 * TestPromotionToSurvivor 20m 47 SURVIVOR 49 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 50 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 51 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 52 * -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m 53 * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 54 * TestPromotionToSurvivor 8m 9 SURVIVOR 55 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 56 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 57 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 58 * -XX:SurvivorAlignmentInBytes=64 -XX:OldSize=128m 59 * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 60 * TestPromotionToSurvivor 20m 87 SURVIVOR 61 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 62 * -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m 63 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 64 * -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m 65 * -XX:MaxHeapSize=384m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 66 * TestPromotionToSurvivor 10m 9 SURVIVOR 67 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 68 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 69 * -XX:SurvivorRatio=1 -XX:+UnlockExperimentalVMOptions 70 * -XX:SurvivorAlignmentInBytes=128 -XX:OldSize=128m 71 * -XX:MaxHeapSize=256m -XX:-ExplicitGCInvokesConcurrent -XX:-ResizePLAB 72 * TestPromotionToSurvivor 20m 147 SURVIVOR 73 */ 74 public class TestPromotionToSurvivor { 75 public static void main(String args[]) { 76 SurvivorAlignmentTestMain test 77 = SurvivorAlignmentTestMain.fromArgs(args); 78 System.out.println(test); 79 80 long expectedUsage = test.getExpectedMemoryUsage(); 81 test.baselineMemoryAllocation(); 82 SurvivorAlignmentTestMain.WHITE_BOX.fullGC(); 83 84 test.allocate(); 85 SurvivorAlignmentTestMain.WHITE_BOX.youngGC(); 86 87 test.verifyMemoryUsage(expectedUsage); 88 } 89 }