Path: blob/master/test/hotspot/jtreg/gc/g1/TestMarkStackSizes.java
40942 views
/*1* Copyright (c) 2020, 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 TestMarkStackSizes27* @bug 823885528* @summary Consistency checks for marking flag related options.29* @requires vm.gc.G130* @library /test/lib31* @modules java.base/jdk.internal.misc32* java.management33* @run driver gc.g1.TestMarkStackSizes34*/3536import java.util.ArrayList;37import java.util.Collections;3839import jdk.test.lib.process.OutputAnalyzer;40import jdk.test.lib.process.ProcessTools;4142public class TestMarkStackSizes {43private static void runTest(boolean shouldSucceed, String... extraArgs) throws Exception {44ArrayList<String> testArguments = new ArrayList<String>();4546testArguments.add("-XX:+UseG1GC");47testArguments.add("-Xmx12m");48testArguments.add("-XX:+PrintFlagsFinal");49Collections.addAll(testArguments, extraArgs);50testArguments.add("-version");5152ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testArguments);5354OutputAnalyzer output = new OutputAnalyzer(pb.start());5556System.out.println(output.getStderr());5758if (shouldSucceed) {59long markStackSize = Long.parseLong(output.firstMatch("MarkStackSize\\s+=\\s(\\d+)",1));60long markStackSizeMax = Long.parseLong(output.firstMatch("MarkStackSizeMax\\s+=\\s(\\d+)",1));61long concGCThreads = Long.parseLong(output.firstMatch("ConcGCThreads\\s+=\\s(\\d+)",1));62long parallelGCThreads = Long.parseLong(output.firstMatch("ParallelGCThreads\\s+=\\s(\\d+)",1));6364System.out.println("MarkStackSize=" + markStackSize + " MarkStackSizeMax=" + markStackSizeMax +65"ConcGCThreads=" + concGCThreads + " ParallelGCThreads=" + parallelGCThreads);6667output.shouldHaveExitValue(0);68} else {69output.shouldNotHaveExitValue(0);70}71}7273public static void main(String[] args) throws Exception {74runTest(false, "-XX:MarkStackSize=0");75runTest(false, "-XX:MarkStackSizeMax=0");7677runTest(true, "-XX:MarkStackSize=100", "-XX:MarkStackSizeMax=101");78runTest(true, "-XX:MarkStackSize=101", "-XX:MarkStackSizeMax=101");79runTest(false, "-XX:MarkStackSize=101", "-XX:MarkStackSizeMax=100");8081runTest(true, "-XX:ConcGCThreads=3", "-XX:ParallelGCThreads=3");82runTest(true, "-XX:ConcGCThreads=0", "-XX:ParallelGCThreads=3");83runTest(false, "-XX:ConcGCThreads=4", "-XX:ParallelGCThreads=3");8485// With that high ParallelGCThreads the default ergonomics would calculate86// a mark stack size higher than maximum mark stack size.87runTest(true, "-XX:ParallelGCThreads=100", "-XX:MarkStackSizeMax=100");88}89}909192