|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, Red Hat, Inc. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +/* |
| 25 | + * @test |
| 26 | + * @bug 8241486 |
| 27 | + * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) |
| 28 | + * @requires vm.flavor == "server" & !vm.graal.enabled |
| 29 | + * @requires vm.gc.G1 & vm.gc.Shenandoah & vm.gc.Z & vm.gc.Epsilon |
| 30 | + * @library /test/lib |
| 31 | + * @modules java.base/jdk.internal.misc |
| 32 | + * java.management |
| 33 | + * @run driver TestNoWarningLoopStripMiningIterSet |
| 34 | + */ |
| 35 | + |
| 36 | +import jdk.test.lib.Asserts; |
| 37 | +import jdk.test.lib.process.ProcessTools; |
| 38 | +import jdk.test.lib.process.OutputAnalyzer; |
| 39 | +import java.util.function.Consumer; |
| 40 | +import java.util.Arrays; |
| 41 | +import java.util.List; |
| 42 | + |
| 43 | +public class TestNoWarningLoopStripMiningIterSet { |
| 44 | + static final String CLSOnLSMEqualZero = "When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1"; |
| 45 | + static final String CLSOffLSMGreaterZero = "Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0"; |
| 46 | + |
| 47 | + public static void testWith(Consumer<OutputAnalyzer> check, String msg, boolean cls, int iters, String... args) throws Exception { |
| 48 | + String[] cmds = new String[args.length + 3]; |
| 49 | + cmds[0] = "-XX:+UnlockExperimentalVMOptions"; |
| 50 | + System.arraycopy(args, 0, cmds, 1, args.length); |
| 51 | + cmds[args.length + 1] = "-XX:+PrintFlagsFinal"; |
| 52 | + cmds[args.length + 2] = "-version"; |
| 53 | + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds); |
| 54 | + OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
| 55 | + output.shouldHaveExitValue(0); |
| 56 | + |
| 57 | + check.accept(output); |
| 58 | + |
| 59 | + Asserts.assertEQ(output.firstMatch("(.+?) UseCountedLoopSafepoints.+?= (.+?) (.+?)", 2), Boolean.toString(cls), msg + ", but got wrong CLS"); |
| 60 | + Asserts.assertEQ(output.firstMatch("(.+?) LoopStripMiningIter.+?= (.+?) (.+?)", 2), String.valueOf(iters), msg + ", but got wrong LSM"); |
| 61 | + } |
| 62 | + |
| 63 | + public static void main(String[] args) throws Exception { |
| 64 | + for (String gc : List.of("-XX:+UseG1GC", "-XX:+UseZGC", "-XX:+UseShenandoahGC", "-XX:+UseEpsilonGC")) { |
| 65 | + testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc); |
| 66 | + testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc); |
| 67 | + testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc); |
| 68 | + testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc); |
| 69 | + } |
| 70 | + } |
| 71 | +} |
0 commit comments