Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.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* when their age exceeded tenuring threshold are not aligned to28* SurvivorAlignmentInBytes value.29* @requires vm.gc != "Shenandoah"30* @library /testlibrary /testlibrary/whitebox31* @build TestPromotionFromSurvivorToTenuredAfterMinorGC32* SurvivorAlignmentTestMain AlignmentHelper33* @run main ClassFileInstaller sun.hotspot.WhiteBox34* sun.hotspot.WhiteBox$WhiteBoxPermission35* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions36* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m37* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=138* -XX:-ExplicitGCInvokesConcurrent39* -XX:+UnlockExperimentalVMOptions40* -XX:SurvivorAlignmentInBytes=3241* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 942* TENURED43* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions44* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m45* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=146* -XX:-ExplicitGCInvokesConcurrent47* -XX:+UnlockExperimentalVMOptions48* -XX:SurvivorAlignmentInBytes=3249* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 4750* TENURED51* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions52* -XX:+WhiteBoxAPI -XX:NewSize=200m -XX:MaxNewSize=200m53* -XX:OldSize=32M -XX:MaxHeapSize=232m -XX:SurvivorRatio=154* -XX:-ExplicitGCInvokesConcurrent55* -XX:+UnlockExperimentalVMOptions56* -XX:SurvivorAlignmentInBytes=6457* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 958* TENURED59* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions60* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m61* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=162* -XX:-ExplicitGCInvokesConcurrent63* -XX:+UnlockExperimentalVMOptions64* -XX:SurvivorAlignmentInBytes=6465* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 8766* TENURED67* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions68* -XX:+WhiteBoxAPI -XX:NewSize=256m -XX:MaxNewSize=256m69* -XX:OldSize=32M -XX:MaxHeapSize=288m -XX:SurvivorRatio=170* -XX:-ExplicitGCInvokesConcurrent71* -XX:+UnlockExperimentalVMOptions72* -XX:SurvivorAlignmentInBytes=12873* TestPromotionFromSurvivorToTenuredAfterMinorGC 10m 974* TENURED75* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions76* -XX:+WhiteBoxAPI -XX:NewSize=128m -XX:MaxNewSize=128m77* -XX:OldSize=32M -XX:MaxHeapSize=160m -XX:SurvivorRatio=178* -XX:-ExplicitGCInvokesConcurrent79* -XX:+UnlockExperimentalVMOptions80* -XX:SurvivorAlignmentInBytes=12881* TestPromotionFromSurvivorToTenuredAfterMinorGC 20m 14782* TENURED83*/84public class TestPromotionFromSurvivorToTenuredAfterMinorGC {85public static void main(String args[]) throws Exception {86SurvivorAlignmentTestMain test87= SurvivorAlignmentTestMain.fromArgs(args);88System.out.println(test);8990long expectedMemoryUsage = test.getExpectedMemoryUsage();91test.baselineMemoryAllocation();92SurvivorAlignmentTestMain.WHITE_BOX.fullGC();93// increase expected usage by current old gen usage94expectedMemoryUsage += SurvivorAlignmentTestMain.getAlignmentHelper(95SurvivorAlignmentTestMain.HeapSpace.TENURED)96.getActualMemoryUsage();9798test.allocate();99for (int i = 0; i <= SurvivorAlignmentTestMain.MAX_TENURING_THRESHOLD; i++) {100SurvivorAlignmentTestMain.WHITE_BOX.youngGC();101}102103// Sometimes we see that data unrelated to the test has been allocated during104// the loop. This data is included in the expectedMemoryUsage since we look105// through all threads to see what they allocated. If this data is still in106// the survivor area however, it should not be included in expectedMemoryUsage107// since the verification below only look at what's in tenured space.108expectedMemoryUsage -= SurvivorAlignmentTestMain.getAlignmentHelper(109SurvivorAlignmentTestMain.HeapSpace.SURVIVOR)110.getActualMemoryUsage();111test.verifyMemoryUsage(expectedMemoryUsage);112}113}114115116