Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8241486: G1/Z give warning when using LoopStripMiningIter and turn of…
…f LoopStripMiningIter (0)

Reviewed-by: thartmann, kvn
  • Loading branch information
rwestrel committed Aug 21, 2020
1 parent fefb9c8 commit 3ccb4939b7383d1a658cdfc7648bb40e8d9bb130
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 11 deletions.
@@ -403,17 +403,6 @@ bool CompilerConfig::check_args_consistency(bool status) {
}
FLAG_SET_CMDLINE(PostLoopMultiversioning, false);
}
if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) {
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
warning("When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1");
}
LoopStripMiningIter = 1;
} else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) {
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
warning("Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0");
}
LoopStripMiningIter = 0;
}
#endif // COMPILER2

if (Arguments::is_interpreter_only()) {
@@ -762,6 +762,7 @@
product(uintx, LoopStripMiningIter, 0, \
"Number of iterations in strip mined loop") \
range(0, max_juint) \
constraint(LoopStripMiningIterConstraintFunc, AfterErgo) \
\
product(uintx, LoopStripMiningIterShortLoop, 0, \
"Loop with fewer iterations are not strip mined") \
@@ -379,3 +379,26 @@ JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) {

return JVMFlag::SUCCESS;
}

#ifdef COMPILER2
JVMFlag::Error LoopStripMiningIterConstraintFunc(uintx value, bool verbose) {
if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) {
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
JVMFlag::printError(verbose,
"When counted loop safepoints are enabled, "
"LoopStripMiningIter must be at least 1 "
"(a safepoint every 1 iteration): setting it to 1\n");
}
LoopStripMiningIter = 1;
} else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) {
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
JVMFlag::printError(verbose,
"Disabling counted safepoints implies no loop strip mining: "
"setting LoopStripMiningIter to 0\n");
}
LoopStripMiningIter = 0;
}

return JVMFlag::SUCCESS;
}
#endif // COMPILER2
@@ -71,4 +71,8 @@ JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose);

JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose);

#ifdef COMPILER2
JVMFlag::Error LoopStripMiningIterConstraintFunc(uintx value, bool verbose);
#endif

#endif // SHARE_RUNTIME_FLAGS_JVMFLAGCONSTRAINTSCOMPILER_HPP
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2020, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8241486
* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
* @requires vm.flavor == "server" & !vm.graal.enabled
* @requires vm.gc.G1 & vm.gc.Shenandoah & vm.gc.Z & vm.gc.Epsilon
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* @run driver TestNoWarningLoopStripMiningIterSet
*/

import jdk.test.lib.Asserts;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.util.function.Consumer;
import java.util.Arrays;
import java.util.List;

public class TestNoWarningLoopStripMiningIterSet {
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";
static final String CLSOffLSMGreaterZero = "Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0";

public static void testWith(Consumer<OutputAnalyzer> check, String msg, boolean cls, int iters, String... args) throws Exception {
String[] cmds = new String[args.length + 3];
cmds[0] = "-XX:+UnlockExperimentalVMOptions";
System.arraycopy(args, 0, cmds, 1, args.length);
cmds[args.length + 1] = "-XX:+PrintFlagsFinal";
cmds[args.length + 2] = "-version";
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

check.accept(output);

Asserts.assertEQ(output.firstMatch("(.+?) UseCountedLoopSafepoints.+?= (.+?) (.+?)", 2), Boolean.toString(cls), msg + ", but got wrong CLS");
Asserts.assertEQ(output.firstMatch("(.+?) LoopStripMiningIter.+?= (.+?) (.+?)", 2), String.valueOf(iters), msg + ", but got wrong LSM");
}

public static void main(String[] args) throws Exception {
for (String gc : List.of("-XX:+UseG1GC", "-XX:+UseZGC", "-XX:+UseShenandoahGC", "-XX:+UseEpsilonGC")) {
testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc);
testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc);
testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc);
testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc);
}
}
}

0 comments on commit 3ccb493

Please sign in to comment.