Path: blob/master/test/hotspot/jtreg/gc/g1/TestPLABOutput.java
40942 views
/*1* Copyright (c) 2015, 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 TestPLABOutput27* @bug 814058528* @summary Check that G1 does not report empty PLAB statistics in the first evacuation.29* @requires vm.gc.G130* @modules java.base/jdk.internal.misc31* @library /test/lib32* @build sun.hotspot.WhiteBox33* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox34* @run driver gc.g1.TestPLABOutput35*/3637import sun.hotspot.WhiteBox;3839import java.util.regex.Matcher;40import java.util.regex.Pattern;4142import jdk.test.lib.process.OutputAnalyzer;43import jdk.test.lib.process.ProcessTools;4445import static jdk.test.lib.Asserts.*;4647public class TestPLABOutput {4849public static void runTest() throws Exception {50final String[] arguments = {51"-Xbootclasspath/a:.",52"-XX:+UnlockExperimentalVMOptions",53"-XX:+UnlockDiagnosticVMOptions",54"-XX:+WhiteBoxAPI",55"-XX:+UseG1GC",56"-Xmx10M",57"-Xlog:gc+plab=debug",58GCTest.class.getName()59};6061ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(arguments);62OutputAnalyzer output = new OutputAnalyzer(pb.start());6364output.shouldHaveExitValue(0);6566System.out.println(output.getStdout());6768String pattern = ".*GC\\(0\\) .*allocated: (\\d+).*";69Pattern r = Pattern.compile(pattern);70Matcher m = r.matcher(output.getStdout());7172if (!m.find()) {73throw new RuntimeException("Could not find any PLAB statistics output");74}75int allocated = Integer.parseInt(m.group(1));76assertGT(allocated, 0, "Did not allocate any memory during test");77}7879public static void main(String[] args) throws Exception {80runTest();81}8283static class GCTest {84private static final WhiteBox WB = WhiteBox.getWhiteBox();8586public static Object holder;8788public static void main(String [] args) {89holder = new byte[100];90WB.youngGC();91System.out.println(holder);92}93}94}95969798