Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java
41152 views
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 id=G1
26
* @bug 8241486
27
* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
28
* @requires vm.flagless
29
* @requires vm.flavor == "server" & !vm.graal.enabled
30
* @requires vm.gc.G1
31
* @library /test/lib
32
* @run driver TestNoWarningLoopStripMiningIterSet G1
33
*/
34
35
/*
36
* @test id=Shenandoah
37
* @bug 8241486
38
* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
39
* @requires vm.flagless
40
* @requires vm.flavor == "server" & !vm.graal.enabled
41
* @requires vm.gc.Shenandoah
42
* @library /test/lib
43
* @run driver TestNoWarningLoopStripMiningIterSet Shenandoah
44
*/
45
46
/*
47
* @test id=Z
48
* @bug 8241486
49
* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
50
* @requires vm.flagless
51
* @requires vm.flavor == "server" & !vm.graal.enabled
52
* @requires vm.gc.Z
53
* @library /test/lib
54
* @run driver TestNoWarningLoopStripMiningIterSet Z
55
*/
56
57
/*
58
* @test id=Epsilon
59
* @bug 8241486
60
* @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0)
61
* @requires vm.flagless
62
* @requires vm.flavor == "server" & !vm.graal.enabled
63
* @requires vm.gc.Epsilon
64
* @library /test/lib
65
* @run driver TestNoWarningLoopStripMiningIterSet Epsilon
66
*/
67
68
69
import jdk.test.lib.Asserts;
70
import jdk.test.lib.process.ProcessTools;
71
import jdk.test.lib.process.OutputAnalyzer;
72
import java.util.function.Consumer;
73
import java.util.Arrays;
74
import java.util.List;
75
76
public class TestNoWarningLoopStripMiningIterSet {
77
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";
78
static final String CLSOffLSMGreaterZero = "Disabling counted safepoints implies no loop strip mining: setting LoopStripMiningIter to 0";
79
80
public static void testWith(Consumer<OutputAnalyzer> check, String msg, boolean cls, int iters, String... args) throws Exception {
81
String[] cmds = new String[args.length + 3];
82
cmds[0] = "-XX:+UnlockExperimentalVMOptions";
83
System.arraycopy(args, 0, cmds, 1, args.length);
84
cmds[args.length + 1] = "-XX:+PrintFlagsFinal";
85
cmds[args.length + 2] = "-version";
86
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(cmds);
87
OutputAnalyzer output = new OutputAnalyzer(pb.start());
88
output.shouldHaveExitValue(0);
89
90
check.accept(output);
91
92
Asserts.assertEQ(output.firstMatch("(.+?) UseCountedLoopSafepoints.+?= (.+?) (.+?)", 2), Boolean.toString(cls), msg + ", but got wrong CLS");
93
Asserts.assertEQ(output.firstMatch("(.+?) LoopStripMiningIter.+?= (.+?) (.+?)", 2), String.valueOf(iters), msg + ", but got wrong LSM");
94
}
95
96
public static void main(String[] args) throws Exception {
97
String gc = "-XX:+Use" + args[0] + "GC";
98
testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc);
99
testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc);
100
testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc);
101
testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc);
102
}
103
}
104
105