Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 6a85e14

Browse files
committed
8241486: G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
Reviewed-by: thartmann, kvn
1 parent 56d8e8a commit 6a85e14

File tree

5 files changed

+99
-11
lines changed

5 files changed

+99
-11
lines changed

src/hotspot/share/compiler/compilerDefinitions.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,6 @@ bool CompilerConfig::check_args_consistency(bool status) {
403403
}
404404
FLAG_SET_CMDLINE(PostLoopMultiversioning, false);
405405
}
406-
if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) {
407-
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
408-
warning("When counted loop safepoints are enabled, LoopStripMiningIter must be at least 1 (a safepoint every 1 iteration): setting it to 1");
409-
}
410-
LoopStripMiningIter = 1;
411-
} else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) {
412-
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
413-
warning("Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0");
414-
}
415-
LoopStripMiningIter = 0;
416-
}
417406
#endif // COMPILER2
418407

419408
if (Arguments::is_interpreter_only()) {

src/hotspot/share/opto/c2_globals.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,7 @@
762762
product(uintx, LoopStripMiningIter, 0, \
763763
"Number of iterations in strip mined loop") \
764764
range(0, max_juint) \
765+
constraint(LoopStripMiningIterConstraintFunc, AfterErgo) \
765766
\
766767
product(uintx, LoopStripMiningIterShortLoop, 0, \
767768
"Loop with fewer iterations are not strip mined") \

src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,26 @@ JVMFlag::Error RTMTotalCountIncrRateConstraintFunc(int value, bool verbose) {
379379

380380
return JVMFlag::SUCCESS;
381381
}
382+
383+
#ifdef COMPILER2
384+
JVMFlag::Error LoopStripMiningIterConstraintFunc(uintx value, bool verbose) {
385+
if (UseCountedLoopSafepoints && LoopStripMiningIter == 0) {
386+
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
387+
JVMFlag::printError(verbose,
388+
"When counted loop safepoints are enabled, "
389+
"LoopStripMiningIter must be at least 1 "
390+
"(a safepoint every 1 iteration): setting it to 1\n");
391+
}
392+
LoopStripMiningIter = 1;
393+
} else if (!UseCountedLoopSafepoints && LoopStripMiningIter > 0) {
394+
if (!FLAG_IS_DEFAULT(UseCountedLoopSafepoints) || !FLAG_IS_DEFAULT(LoopStripMiningIter)) {
395+
JVMFlag::printError(verbose,
396+
"Disabling counted safepoints implies no loop strip mining: "
397+
"setting LoopStripMiningIter to 0\n");
398+
}
399+
LoopStripMiningIter = 0;
400+
}
401+
402+
return JVMFlag::SUCCESS;
403+
}
404+
#endif // COMPILER2

src/hotspot/share/runtime/flags/jvmFlagConstraintsCompiler.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ JVMFlag::Error NodeLimitFudgeFactorConstraintFunc(intx value, bool verbose);
7171

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

74+
#ifdef COMPILER2
75+
JVMFlag::Error LoopStripMiningIterConstraintFunc(uintx value, bool verbose);
76+
#endif
77+
7478
#endif // SHARE_RUNTIME_FLAGS_JVMFLAGCONSTRAINTSCOMPILER_HPP
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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

Comments
 (0)