Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java
48799 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* when their age exceeded tenuring threshold are not aligned to28* SurvivorAlignmentInBytes value.29* @library /testlibrary /testlibrary/whitebox30* @build TestPromotionFromSurvivorToTenuredAfterMinorGC31* 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=160m -XX:SurvivorRatio=137* -XX:-ExplicitGCInvokesConcurrent38* -XX:+UnlockExperimentalVMOptions39* -XX:SurvivorAlignmentInBytes=3240* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 941* TENURED42* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions43* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m44* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=145* -XX:-ExplicitGCInvokesConcurrent46* -XX:+UnlockExperimentalVMOptions47* -XX:SurvivorAlignmentInBytes=3248* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 4749* TENURED50* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions51* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m52* -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=153* -XX:-ExplicitGCInvokesConcurrent54* -XX:+UnlockExperimentalVMOptions55* -XX:SurvivorAlignmentInBytes=6456* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 957* TENURED58* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions59* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m60* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=161* -XX:-ExplicitGCInvokesConcurrent62* -XX:+UnlockExperimentalVMOptions63* -XX:SurvivorAlignmentInBytes=6464* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 8765* TENURED66* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions67* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m68* -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=169* -XX:-ExplicitGCInvokesConcurrent70* -XX:+UnlockExperimentalVMOptions71* -XX:SurvivorAlignmentInBytes=12872* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 973* TENURED74* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions75* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m76* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=177* -XX:-ExplicitGCInvokesConcurrent78* -XX:+UnlockExperimentalVMOptions79* -XX:SurvivorAlignmentInBytes=12880* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 14781* TENURED82*/83public class TestPromotionFromSurvivorToTenuredAfterMinorGC {84public static void main(String args[]) throws Exception {85SurvivorAlignmentTestMain test86= SurvivorAlignmentTestMain.fromArgs(args);87System.out.println(test);8889long expectedMemoryUsage = test.getExpectedMemoryUsage();90test.baselineMemoryAllocation();91SurvivorAlignmentTestMain.WHITE_BOX.fullGC();92// increase expected usage by current old gen usage93expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(94SurvivorAlignmentTestMain.HeapSpace.TENURED)95.getActualMemoryUsage();9697test.allocate();98for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD;99i++) {100SurvivorAlignmentTestMain.WHITE_BOX.youngGC();101}102103test.verifyMemoryUsage(expectedMemoryUsage);104}105}106107108