Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/controldependency/TestAntiDependentMembar.java
41149 views
1
/*
2
* Copyright (c) 2019, 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
/**
25
* @test
26
* @bug 8228772
27
* @summary Test correct insertion of anti-dependencies if load is already control dependent on membar.
28
* @run main/othervm -Xbatch -XX:-TieredCompilation
29
* -XX:CompileCommand=inline,compiler.controldependency.TestAntiDependentMembar::hitSearchLimit
30
* compiler.controldependency.TestAntiDependentMembar
31
* @run main/othervm -Xbatch -XX:-TieredCompilation
32
* -XX:CompileCommand=inline,compiler.controldependency.TestAntiDependentMembar::hitSearchLimit
33
* -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:DominatorSearchLimit=0
34
* compiler.controldependency.TestAntiDependentMembar
35
*/
36
37
package compiler.controldependency;
38
39
public class TestAntiDependentMembar {
40
41
static volatile int step1 = 0;
42
static volatile int step2 = 0;
43
44
public static int test1(int count, int b1, int b2) {
45
int[] result = {0};
46
47
// Complex control flow to generate Region with 4 paths and therefore bail out of Node::dominates
48
if (b1 == 0) {
49
count += 1;
50
} else if (b1 == 1) {
51
if (b2 == 1) {
52
count += 2;
53
}
54
}
55
56
for (int i = 0; i < count; ++i) {
57
// Volatile field write adds a membar
58
step1 = i;
59
// Load that is dependent on the membar
60
result[0] += count;
61
}
62
return result[0];
63
}
64
65
// Same as test1 but bailing out of Node::dominates due to hitting DominatorSearchLimit
66
public static int test2(int count) {
67
int[] result = {0};
68
69
// Large method with regions to hit the DominatorSearchLimit
70
hitSearchLimit();
71
72
for (int i = 0; i < count; ++i) {
73
step1 = i;
74
result[0] += count;
75
}
76
return result[0];
77
}
78
79
// Same as test2 but with multiple membars before the load
80
public static int test3(int count) {
81
int[] result = {0};
82
83
hitSearchLimit();
84
85
for (int i = 0; i < count; ++i) {
86
step1 = i;
87
step2 = i;
88
step1 = i;
89
step2 = i;
90
result[0] += count;
91
}
92
return result[0];
93
}
94
95
public static void main(String[] args) {
96
for (int i = 0; i < 50_000; ++i) {
97
test1(10, 0, 0);
98
test1(10, 1, 1);
99
test1(10, 1, 0);
100
test1(10, 0, 1);
101
test2(10);
102
test3(10);
103
}
104
}
105
106
public static void hitSearchLimit() {
107
step1++;
108
step2++;
109
step1++;
110
step2++;
111
step1++;
112
step2++;
113
step1++;
114
step2++;
115
step1++;
116
step2++;
117
step1++;
118
step2++;
119
step1++;
120
step2++;
121
step1++;
122
step2++;
123
step1++;
124
step2++;
125
step1++;
126
step2++;
127
step1++;
128
step2++;
129
step1++;
130
step2++;
131
step1++;
132
step2++;
133
step1++;
134
step2++;
135
step1++;
136
step2++;
137
step1++;
138
step2++;
139
step1++;
140
step2++;
141
step1++;
142
step2++;
143
step1++;
144
step2++;
145
step1++;
146
step2++;
147
step1++;
148
step2++;
149
step1++;
150
step2++;
151
step1++;
152
step2++;
153
step1++;
154
step2++;
155
step1++;
156
step2++;
157
step1++;
158
step2++;
159
step1++;
160
step2++;
161
step1++;
162
step2++;
163
step1++;
164
step2++;
165
step1++;
166
step2++;
167
step1++;
168
step2++;
169
step1++;
170
step2++;
171
step1++;
172
step2++;
173
step1++;
174
step2++;
175
step1++;
176
step2++;
177
step1++;
178
step2++;
179
step1++;
180
step2++;
181
step1++;
182
step2++;
183
step1++;
184
step2++;
185
step1++;
186
step2++;
187
step1++;
188
step2++;
189
step1++;
190
step2++;
191
step1++;
192
step2++;
193
step1++;
194
step2++;
195
step1++;
196
step2++;
197
step1++;
198
step2++;
199
step1++;
200
step2++;
201
step1++;
202
step2++;
203
step1++;
204
step2++;
205
step1++;
206
step2++;
207
step1++;
208
step2++;
209
step1++;
210
step2++;
211
step1++;
212
step2++;
213
step1++;
214
step2++;
215
step1++;
216
step2++;
217
step1++;
218
step2++;
219
step1++;
220
step2++;
221
step1++;
222
step2++;
223
step1++;
224
step2++;
225
step1++;
226
step2++;
227
step1++;
228
step2++;
229
step1++;
230
step2++;
231
step1++;
232
step2++;
233
step1++;
234
step2++;
235
step1++;
236
step2++;
237
step1++;
238
step2++;
239
step1++;
240
step2++;
241
step1++;
242
step2++;
243
step1++;
244
step2++;
245
step1++;
246
step2++;
247
step1++;
248
step2++;
249
step1++;
250
step2++;
251
step1++;
252
step2++;
253
step1++;
254
step2++;
255
step1++;
256
step2++;
257
step1++;
258
step2++;
259
step1++;
260
step2++;
261
step1++;
262
step2++;
263
step1++;
264
step2++;
265
step1++;
266
step2++;
267
step1++;
268
step2++;
269
step1++;
270
step2++;
271
step1++;
272
step2++;
273
step1++;
274
step2++;
275
step1++;
276
step2++;
277
step1++;
278
step2++;
279
step1++;
280
step2++;
281
step1++;
282
step2++;
283
step1++;
284
step2++;
285
step1++;
286
step2++;
287
step1++;
288
step2++;
289
step1++;
290
step2++;
291
step1++;
292
step2++;
293
step1++;
294
step2++;
295
step1++;
296
step2++;
297
step1++;
298
step2++;
299
step1++;
300
step2++;
301
step1++;
302
step2++;
303
step1++;
304
step2++;
305
step1++;
306
step2++;
307
step1++;
308
step2++;
309
step1++;
310
step2++;
311
step1++;
312
step2++;
313
step1++;
314
step2++;
315
step1++;
316
step2++;
317
step1++;
318
step2++;
319
step1++;
320
step2++;
321
step1++;
322
step2++;
323
step1++;
324
step2++;
325
step1++;
326
step2++;
327
step1++;
328
step2++;
329
step1++;
330
step2++;
331
step1++;
332
step2++;
333
step1++;
334
step2++;
335
step1++;
336
step2++;
337
step1++;
338
step2++;
339
step1++;
340
step2++;
341
step1++;
342
step2++;
343
step1++;
344
step2++;
345
step1++;
346
step2++;
347
step1++;
348
step2++;
349
step1++;
350
step2++;
351
step1++;
352
step2++;
353
step1++;
354
step2++;
355
step1++;
356
step2++;
357
step1++;
358
step2++;
359
step1++;
360
step2++;
361
step1++;
362
step2++;
363
step1++;
364
step2++;
365
step1++;
366
step2++;
367
step1++;
368
step2++;
369
step1++;
370
step2++;
371
step1++;
372
step2++;
373
step1++;
374
step2++;
375
step1++;
376
step2++;
377
step1++;
378
step2++;
379
step1++;
380
step2++;
381
step1++;
382
step2++;
383
step1++;
384
step2++;
385
step1++;
386
step2++;
387
step1++;
388
step2++;
389
step1++;
390
step2++;
391
step1++;
392
step2++;
393
step1++;
394
step2++;
395
step1++;
396
step2++;
397
step1++;
398
step2++;
399
step1++;
400
step2++;
401
step1++;
402
step2++;
403
step1++;
404
step2++;
405
step1++;
406
step2++;
407
step1++;
408
step2++;
409
step1++;
410
step2++;
411
step1++;
412
step2++;
413
step1++;
414
step2++;
415
step1++;
416
step2++;
417
step1++;
418
step2++;
419
step1++;
420
step2++;
421
step1++;
422
step2++;
423
step1++;
424
step2++;
425
step1++;
426
step2++;
427
step1++;
428
step2++;
429
step1++;
430
step2++;
431
step1++;
432
step2++;
433
step1++;
434
step2++;
435
step1++;
436
step2++;
437
step1++;
438
step2++;
439
step1++;
440
step2++;
441
step1++;
442
step2++;
443
step1++;
444
step2++;
445
step1++;
446
step2++;
447
step1++;
448
step2++;
449
}
450
}
451
452