Path: blob/master/test/hotspot/jtreg/gc/g1/TestHumongousRemsetsMatch.java
40942 views
/*1* Copyright (c) 2018, 2021, 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*/2223package gc.g1;2425/*26* @test TestHumongousRemSetsMatch27* @bug 820542628* @summary Test to make sure that humongous object remset states are in sync29* @requires vm.gc.G1 & os.maxMemory >= 2G30* @library /test/lib31* @build sun.hotspot.WhiteBox32* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox33* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -Xmx512M -Xms512M -Xmn10M -XX:ParallelGCThreads=2 -XX:-UseDynamicNumberOfGCThreads -XX:+UseG1GC -XX:+WhiteBoxAPI -XX:G1HeapRegionSize=1M -XX:+VerifyAfterGC -Xlog:gc,gc+remset+tracking=trace gc.g1.TestHumongousRemsetsMatch34*/3536import sun.hotspot.WhiteBox;3738public class TestHumongousRemsetsMatch {3940// G1 at the moment uses one thread every this amount of regions.41private static final int WorkerThreadBoundary = 384;4243private static final int ObjSizeInRegions = 17;44private static final int M = 1024 * 1024;45private static final int TypeArrayObjSize = ObjSizeInRegions * M / 4 /* sizeof(int) */ - 1024 /* > header size */;4647public static void main(String[] args) throws Exception {48WhiteBox wb = WhiteBox.getWhiteBox();4950for (int j = 0; j < 3; j++) {51wb.fullGC(); // Start with a clean slate5253// It may happen that our 7-region sized humongous objects may just be "misaligned"54// so that they do not cross the region 384 boundary. Try to counter this by offsetting55// the humongous objects just a little.56Object alignmentFudge = new int[(j + 1) * M / 4 /* sizeof(int) */ - 1024];5758// Fill the heap so that more than WorkerThreadBoundary regions are occupied with humongous objects59// and hopefully one of these objects crosses the region WorkerThreadBoundary boundary.60Object[] lotsOfHumongousObjects = new Object[(WorkerThreadBoundary / ObjSizeInRegions) + 3];6162for (int i = 0; i < lotsOfHumongousObjects.length; i++) {63lotsOfHumongousObjects[i] = new int[TypeArrayObjSize];64}6566wb.fullGC();6768// Trigger a concurrent cycle and wait until the Remark pause69wb.g1StartConcMarkCycle();70while (wb.g1InConcurrentMark()) {71Thread.sleep(200);72}73wb.youngGC(); // Trigger verification error.7475System.out.println(lotsOfHumongousObjects + " " + alignmentFudge);76}77}78}79808182