Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.java
32284 views
/*1* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 803132326* @summary Verify that objects promoted from survivor space to tenured space27* during full GC are not aligned to SurvivorAlignmentInBytes value.28* @requires vm.gc != "Shenandoah"29* @library /testlibrary /testlibrary/whitebox30* @build TestPromotionFromSurvivorToTenuredAfterFullGC31* SurvivorAlignmentTestMain AlignmentHelper32* @run main ClassFileInstaller sun.hotspot.WhiteBox33* sun.hotspot.WhiteBox$WhiteBoxPermission34* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions35* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m36* -XX:OldSize=32m -XX:MaxHeapSize=160m37* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent38* -XX:+UnlockExperimentalVMOptions39* -XX:SurvivorAlignmentInBytes=3240* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED41* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions42* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m43* -XX:OldSize=32m -XX:MaxHeapSize=160m44* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent45* -XX:+UnlockExperimentalVMOptions46* -XX:SurvivorAlignmentInBytes=3247* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 4748* TENURED49* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions50* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m51* -XX:OldSize=32m -XX:MaxHeapSize=232m52* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent53* -XX:+UnlockExperimentalVMOptions54* -XX:SurvivorAlignmentInBytes=6455* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED56* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions57* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m58* -XX:OldSize=32m -XX:MaxHeapSize=160m59* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent60* -XX:+UnlockExperimentalVMOptions61* -XX:SurvivorAlignmentInBytes=6462* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 8763* TENURED64* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions65* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m66* -XX:OldSize=32M -XX:MaxHeapSize=288m67* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent68* -XX:+UnlockExperimentalVMOptions69* -XX:SurvivorAlignmentInBytes=12870* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 971* TENURED72* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions73* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m74* -XX:OldSize=32m -XX:MaxHeapSize=160m75* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent76* -XX:+UnlockExperimentalVMOptions77* -XX:SurvivorAlignmentInBytes=12878* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 14779* TENURED80*/81public class TestPromotionFromSurvivorToTenuredAfterFullGC {82public static void main(String args[]) {83SurvivorAlignmentTestMain test84= SurvivorAlignmentTestMain.fromArgs(args);85System.out.println(test);8687long expectedMemoryUsage = test.getExpectedMemoryUsage();88test.baselineMemoryAllocation();89System.gc();90// increase expected usage by current old gen usage91expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(92SurvivorAlignmentTestMain.HeapSpace.TENURED)93.getActualMemoryUsage();9495test.allocate();96SurvivorAlignmentTestMain.WHITE_BOX.youngGC();97System.gc();9899test.verifyMemoryUsage(expectedMemoryUsage);100}101}102103104