Path: blob/jdk8u272-b10-aarch32-20201026/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterFullGC.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* during full GC are not aligned to SurvivorAlignmentInBytes value.28* @library /testlibrary /testlibrary/whitebox29* @build TestPromotionFromSurvivorToTenuredAfterFullGC30* SurvivorAlignmentTestMain AlignmentHelper31* @run main ClassFileInstaller sun.hotspot.WhiteBox32* sun.hotspot.WhiteBox$WhiteBoxPermission33* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions34* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m35* -XX:OldSize=32m -XX:MaxHeapSize=160m36* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent37* -XX:+UnlockExperimentalVMOptions38* -XX:SurvivorAlignmentInBytes=3239* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED40* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions41* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m42* -XX:OldSize=32m -XX:MaxHeapSize=160m43* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent44* -XX:+UnlockExperimentalVMOptions45* -XX:SurvivorAlignmentInBytes=3246* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 4747* TENURED48* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions49* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m50* -XX:OldSize=32m -XX:MaxHeapSize=232m51* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent52* -XX:+UnlockExperimentalVMOptions53* -XX:SurvivorAlignmentInBytes=6454* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 9 TENURED55* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions56* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m57* -XX:OldSize=32m -XX:MaxHeapSize=160m58* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent59* -XX:+UnlockExperimentalVMOptions60* -XX:SurvivorAlignmentInBytes=6461* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 8762* TENURED63* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions64* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m65* -XX:OldSize=32M -XX:MaxHeapSize=288m66* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent67* -XX:+UnlockExperimentalVMOptions68* -XX:SurvivorAlignmentInBytes=12869* TestPromotionFromSurvivorToTenuredAfterFullGC 10m 970* TENURED71* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions72* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m73* -XX:OldSize=32m -XX:MaxHeapSize=160m74* -XX:SurvivorRatio=1 -XX:-ExplicitGCInvokesConcurrent75* -XX:+UnlockExperimentalVMOptions76* -XX:SurvivorAlignmentInBytes=12877* TestPromotionFromSurvivorToTenuredAfterFullGC 20m 14778* TENURED79*/80public class TestPromotionFromSurvivorToTenuredAfterFullGC {81public static void main(String args[]) {82SurvivorAlignmentTestMain test83= SurvivorAlignmentTestMain.fromArgs(args);84System.out.println(test);8586long expectedMemoryUsage = test.getExpectedMemoryUsage();87test.baselineMemoryAllocation();88System.gc();89// increase expected usage by current old gen usage90expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(91SurvivorAlignmentTestMain.HeapSpace.TENURED)92.getActualMemoryUsage();9394test.allocate();95SurvivorAlignmentTestMain.WHITE_BOX.youngGC();96System.gc();9798test.verifyMemoryUsage(expectedMemoryUsage);99}100}101102103