1 /* 2 * Copyright (c) 2014, 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 survivor space to tenured space 28 * when their age exceeded tenuring threshold are not aligned to 29 * SurvivorAlignmentInBytes value. 30 * @library /testlibrary /testlibrary/whitebox 31 * @build TestPromotionFromSurvivorToTenuredAfterMinorGC 32 * SurvivorAlignmentTestMain AlignmentHelper 33 * @run main ClassFileInstaller sun.hotspot.WhiteBox 34 * sun.hotspot.WhiteBox$WhiteBoxPermission 35 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 36 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 37 * -XX:OldSize=32M -XX:SurvivorRatio=1 38 * -XX:-ExplicitGCInvokesConcurrent 39 * -XX:+UnlockExperimentalVMOptions 40 * -XX:SurvivorAlignmentInBytes=32 41 * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9 42 * TENURED 43 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 44 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 45 * -XX:OldSize=32M -XX:SurvivorRatio=1 46 * -XX:-ExplicitGCInvokesConcurrent 47 * -XX:+UnlockExperimentalVMOptions 48 * -XX:SurvivorAlignmentInBytes=32 49 * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 47 50 * TENURED 51 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 52 * -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m 53 * -XX:OldSize=32M -XX:InitialHeapSize=232m 54 * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent 55 * -XX:+UnlockExperimentalVMOptions 56 * -XX:SurvivorAlignmentInBytes=64 57 * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9 58 * TENURED 59 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 60 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 61 * -XX:OldSize=32M -XX:SurvivorRatio=1 62 * -XX:-ExplicitGCInvokesConcurrent 63 * -XX:+UnlockExperimentalVMOptions 64 * -XX:SurvivorAlignmentInBytes=64 65 * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 87 66 * TENURED 67 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 68 * -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m 69 * -XX:OldSize=32M -XX:InitialHeapSize=288m 70 * -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent 71 * -XX:+UnlockExperimentalVMOptions 72 * -XX:SurvivorAlignmentInBytes=128 73 * TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 9 74 * TENURED 75 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 76 * -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m 77 * -XX:OldSize=32M -XX:SurvivorRatio=1 78 * -XX:-ExplicitGCInvokesConcurrent 79 * -XX:+UnlockExperimentalVMOptions 80 * -XX:SurvivorAlignmentInBytes=128 81 * TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 147 82 * TENURED 83 */ 84 public class TestPromotionFromSurvivorToTenuredAfterMinorGC { 85 public static void main(String args[]) throws Exception { 86 SurvivorAlignmentTestMain test 87 = SurvivorAlignmentTestMain.fromArgs(args); 88 System.out.println(test); 89 90 long expectedMemoryUsage = test.getExpectedMemoryUsage(); 91 test.baselineMemoryAllocation(); 92 SurvivorAlignmentTestMain.WHITE_BOX.fullGC(); 93 // increase expected usage by current old gen usage 94 expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper( 95 SurvivorAlignmentTestMain.HeapSpace.TENURED) 96 .getActualMemoryUsage(); 97 98 test.allocate(); 99 for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD; 100 i++) { 101 SurvivorAlignmentTestMain.WHITE_BOX.youngGC(); 102 } 103 104 test.verifyMemoryUsage(expectedMemoryUsage); 105 } 106 }