Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
41152 views
1
/*
2
* Copyright (c) 2019 SAP SE. 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 8220374 8241492
27
* @summary C2: LoopStripMining doesn't strip as expected
28
* @requires vm.compiler2.enabled
29
*
30
* @library /test/lib
31
* @run driver compiler.loopstripmining.CheckLoopStripMining
32
*/
33
34
package compiler.loopstripmining;
35
36
import jdk.test.lib.Utils;
37
import jdk.test.lib.process.ProcessTools;
38
39
public class CheckLoopStripMining {
40
public static void main(String args[]) throws Exception {
41
ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",
42
// to prevent biased locking handshakes from changing the timing of this test
43
"-XX:-UseBiasedLocking",
44
"-XX:+SafepointTimeout",
45
"-XX:+SafepointALot",
46
"-XX:+AbortVMOnSafepointTimeout",
47
"-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(300),
48
"-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(300),
49
"-XX:-TieredCompilation",
50
"-XX:+UseCountedLoopSafepoints",
51
"-XX:LoopStripMiningIter=1000",
52
"-XX:LoopUnrollLimit=0",
53
"-XX:CompileCommand=compileonly,compiler.loopstripmining.CheckLoopStripMining$Test1::test_loop",
54
"-Xcomp",
55
Test1.class.getName())
56
.shouldHaveExitValue(0)
57
.stdoutShouldContain("sum: 715827882");
58
59
ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",
60
// to prevent biased locking handshakes from changing the timing of this test
61
"-XX:-UseBiasedLocking",
62
"-XX:+SafepointTimeout",
63
"-XX:+SafepointALot",
64
"-XX:+AbortVMOnSafepointTimeout",
65
"-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(300),
66
"-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(300),
67
"-XX:-TieredCompilation",
68
"-XX:+UseCountedLoopSafepoints",
69
"-XX:LoopStripMiningIter=1000",
70
"-XX:LoopUnrollLimit=0",
71
"-XX:-BackgroundCompilation",
72
Test2.class.getName())
73
.shouldHaveExitValue(0);
74
}
75
76
public static class Test1 {
77
public static int test_loop(int x) {
78
int sum = 0;
79
if (x != 0) {
80
for (int y = 1; y < Integer.MAX_VALUE; ++y) {
81
if (y % x == 0) ++sum;
82
}
83
}
84
return sum;
85
}
86
87
public static void main(String args[]) {
88
int sum = test_loop(3);
89
System.out.println("sum: " + sum);
90
}
91
}
92
93
public static class Test2 {
94
public static int test_loop(int start, int stop) {
95
int sum = 0;
96
for (int x = start; x < stop; x++) {
97
sum += x;
98
}
99
return sum;
100
}
101
102
public static void main(String args[]) {
103
for (int i = 0; i < 20_000; i++) {
104
test_loop(0, 1);
105
}
106
test_loop(Integer.MIN_VALUE, 0);
107
test_loop(-1, Integer.MAX_VALUE);
108
test_loop(Integer.MIN_VALUE, Integer.MAX_VALUE);
109
}
110
}
111
}
112
113