Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java
41149 views
1
/*
2
* Copyright (c) 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
/*
25
* @test
26
* @bug 8260370
27
* @summary C2: LoopLimit node is not eliminated
28
*
29
* @run main/othervm
30
* -Xcomp
31
* -XX:CompileOnly=compiler/loopopts/TestLoopLimitNodeElimination
32
* compiler.loopopts.TestLoopLimitNodeElimination
33
*/
34
35
package compiler.loopopts;
36
37
// the test code is derived from a randomly generated test
38
public class TestLoopLimitNodeElimination {
39
private static class MyException extends RuntimeException { }
40
private static final int ITERATIONS = 100000;
41
private static final int SIZE = 400;
42
43
private static int counter = 0;
44
45
int[] array1 = new int[SIZE];
46
47
void test() {
48
int[] array2 = new int[SIZE];
49
array1[2] = 0;
50
array1 = array1;
51
for (long i = 301; i > 2; i -= 2) {
52
int j = 1;
53
do {
54
for (int k = (int) i; k < 1; k++) { }
55
} while (++j < 4);
56
}
57
58
counter++;
59
if (counter == ITERATIONS) {
60
throw new MyException();
61
}
62
}
63
64
public static void main(String[] args) {
65
try {
66
var test = new TestLoopLimitNodeElimination();
67
while (true) {
68
test.test();
69
}
70
} catch (MyException e) {
71
// expected
72
}
73
}
74
}
75
76
77