Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/codegen/TestGCMStorePlacement.java
41149 views
1
/*
2
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. 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
package compiler.codegen;
25
26
import jdk.test.lib.Asserts;
27
28
/**
29
* @test
30
* @bug 8255763 8258894
31
* @summary Tests GCM's store placement in different scenarios (regular and OSR
32
* compilations, reducible and irreducible CFGs).
33
* @library /test/lib /
34
* @run main/othervm -Xbatch compiler.codegen.TestGCMStorePlacement regularReducible1
35
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler.codegen.TestGCMStorePlacement:: compiler.codegen.TestGCMStorePlacement regularReducible2
36
* @run main/othervm -Xcomp -XX:CompileOnly=compiler.codegen.TestGCMStorePlacement:: compiler.codegen.TestGCMStorePlacement regularReducible3
37
* @run main/othervm -Xcomp -XX:CompileOnly=compiler.codegen.TestGCMStorePlacement:: compiler.codegen.TestGCMStorePlacement regularReducible4
38
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler.codegen.TestGCMStorePlacement:: compiler.codegen.TestGCMStorePlacement osrReducible1
39
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler.codegen.TestGCMStorePlacement:: compiler.codegen.TestGCMStorePlacement osrReducible2
40
* @run main/othervm -Xbatch compiler.codegen.TestGCMStorePlacement osrIrreducible1
41
*/
42
43
public class TestGCMStorePlacement {
44
45
static int intCounter;
46
static long longCounter;
47
48
static void testRegularReducible1() {
49
// This should not be placed into the loop.
50
intCounter++;
51
int acc = 0;
52
for (int i = 0; i < 50; i++) {
53
if (i % 2 == 0) {
54
acc += 1;
55
}
56
}
57
return;
58
}
59
60
static void testRegularReducible2() {
61
int i;
62
for (i = 22; i < 384; i++)
63
longCounter += 1;
64
switch (i % 9) {
65
case 49:
66
int i17 = 70;
67
while (i17 > 0) {
68
longCounter = 42;
69
switch (9) {
70
case 97:
71
break;
72
case 11398:
73
for (int i18 = 1; ; );
74
default:
75
}
76
}
77
}
78
}
79
80
static void testRegularReducible3() {
81
int i = 0, i23, i27 = 184;
82
for (int i21 = 0; i21 < 100; i21++) {
83
i23 = 1;
84
longCounter += 1;
85
while (++i23 < 190)
86
switch (i23 % 10) {
87
case 86:
88
continue;
89
case 0:
90
i += 76.854F;
91
for (; i27 < 1; i27++);
92
}
93
}
94
}
95
96
static void testRegularReducible4() {
97
int i16 = 0, i17;
98
longCounter += 1;
99
while (++i16 < 100) {
100
i17 = 0;
101
while (++i17 < 200) {
102
switch ((i16 * 5) + 123) {
103
case 129:
104
break;
105
case 149:
106
break;
107
default:
108
}
109
}
110
}
111
}
112
113
public static void bar() {
114
int[] a = new int[0];
115
long sum = 0;
116
for (int j = 0; j < 0; j++) {
117
sum += (a[j] / (j + 1) + a[j] % (j + 1));
118
}
119
}
120
static void foo() {
121
bar();
122
}
123
124
static void testOsrReducible1() {
125
int count = 100;
126
for (int i = 0; i < 100; i++) {
127
for (int j = 0; j < 100; j++) {
128
foo();
129
try {
130
count = (100000 / count);
131
} catch (Exception e) {}
132
switch (0) {
133
case 0:
134
for (int k = 0; k < 2; k++) {
135
count = 0;
136
}
137
longCounter += 1;
138
}
139
}
140
}
141
}
142
143
static void testOsrReducible2() {
144
System.out.println();
145
boolean cond = false;
146
for (int i = 0; i < 100; i++) {
147
for (int j = 0; j < 100; j++) {
148
intCounter = 42;
149
if (cond) {
150
break;
151
}
152
for (int k = 0; k < 2; k++);
153
}
154
}
155
}
156
157
static void testOsrIrreducible1() {
158
for (int i = 0; i < 30; i++) {
159
switch (i % 3) {
160
case 0:
161
for (int j = 0; j < 50; j++) {
162
// OSR enters here.
163
for (int k = 0; k < 7000; k++) {}
164
if (i % 2 == 0) {
165
break;
166
}
167
}
168
// This should not be placed outside the "case 0" block.
169
intCounter++;
170
break;
171
case 1:
172
break;
173
case 2:
174
break;
175
}
176
}
177
return;
178
}
179
180
public static void main(String[] args) {
181
switch (args[0]) {
182
case "regularReducible1":
183
for (int i = 0; i < 100_000; i++) {
184
intCounter = 0;
185
testRegularReducible1();
186
Asserts.assertEQ(intCounter, 1);
187
}
188
break;
189
case "regularReducible2":
190
longCounter = 0;
191
testRegularReducible2();
192
Asserts.assertEQ(longCounter, 362L);
193
break;
194
case "regularReducible3":
195
for (int i = 0; i < 10; i++) {
196
longCounter = 0;
197
testRegularReducible3();
198
Asserts.assertEQ(longCounter, 100L);
199
}
200
break;
201
case "regularReducible4":
202
for (int i = 0; i < 10; i++) {
203
longCounter = 0;
204
testRegularReducible4();
205
Asserts.assertEQ(longCounter, 1L);
206
}
207
break;
208
case "osrReducible1":
209
longCounter = 0;
210
testOsrReducible1();
211
Asserts.assertEQ(longCounter, 10000L);
212
break;
213
case "osrReducible2":
214
intCounter = 0;
215
testOsrReducible2();
216
Asserts.assertEQ(intCounter, 42);
217
break;
218
case "osrIrreducible1":
219
intCounter = 0;
220
testOsrIrreducible1();
221
Asserts.assertEQ(intCounter, 10);
222
break;
223
default:
224
System.out.println("invalid mode");
225
}
226
}
227
}
228
229