Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java
41152 views
/*1* Copyright (c) 2020, Red Hat, Inc. 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* @test id=G125* @bug 824148626* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)27* @requires vm.flagless28* @requires vm.flavor == "server" & !vm.graal.enabled29* @requires vm.gc.G130* @library /test/lib31* @run driver TestNoWarningLoopStripMiningIterSet G132*/3334/*35* @test id=Shenandoah36* @bug 824148637* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)38* @requires vm.flagless39* @requires vm.flavor == "server" & !vm.graal.enabled40* @requires vm.gc.Shenandoah41* @library /test/lib42* @run driver TestNoWarningLoopStripMiningIterSet Shenandoah43*/4445/*46* @test id=Z47* @bug 824148648* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)49* @requires vm.flagless50* @requires vm.flavor == "server" & !vm.graal.enabled51* @requires vm.gc.Z52* @library /test/lib53* @run driver TestNoWarningLoopStripMiningIterSet Z54*/5556/*57* @test id=Epsilon58* @bug 824148659* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)60* @requires vm.flagless61* @requires vm.flavor == "server" & !vm.graal.enabled62* @requires vm.gc.Epsilon63* @library /test/lib64* @run driver TestNoWarningLoopStripMiningIterSet Epsilon65*/666768import jdk.test.lib.Asserts;69import jdk.test.lib.process.ProcessTools;70import jdk.test.lib.process.OutputAnalyzer;71import java.util.function.Consumer;72import java.util.Arrays;73import java.util.List;7475public class TestNoWarningLoopStripMiningIterSet {76static final String CLSOnLSMEqualZero = "When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1";77static final String CLSOffLSMGreaterZero = "Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0";7879public static void testWith(Consumer<OutputAnalyzer> check, String msg, boolean cls, int iters, String... args) throws Exception {80String[] cmds = new String[args.length + 3];81cmds[0] = "-XX:+UnlockExperimentalVMOptions";82System.arraycopy(args, 0, cmds, 1, args.length);83cmds[args.length + 1] = "-XX:+PrintFlagsFinal";84cmds[args.length + 2] = "-version";85ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);86OutputAnalyzer output = new OutputAnalyzer(pb.start());87output.shouldHaveExitValue(0);8889check.accept(output);9091Asserts.assertEQ(output.firstMatch("(.+?) UseCountedLoopSafepoints.+?= (.+?) (.+?)", 2), Boolean.toString(cls), msg + ", but got wrong CLS");92Asserts.assertEQ(output.firstMatch("(.+?) LoopStripMiningIter.+?= (.+?) (.+?)", 2), String.valueOf(iters), msg + ", but got wrong LSM");93}9495public static void main(String[] args) throws Exception {96String gc = "-XX:+Use" + args[0] + "GC";97testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc);98testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc);99testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc);100testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc);101}102}103104105