Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/TestDeadOuterStripMinedLoop.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 8235452
27
* @library /test/lib /
28
* @summary Test loop strip mining verification with dying outer loop.
29
* @run main/othervm -Xbatch -XX:-TieredCompilation
30
* compiler.loopstripmining.TestDeadOuterStripMinedLoop
31
*/
32
33
package compiler.loopstripmining;
34
35
import jdk.test.lib.Asserts;
36
37
public class TestDeadOuterStripMinedLoop {
38
39
public static int test(boolean b) {
40
int res = 5000;
41
for (int i = 0; i < 42; i++) {
42
if (!b) {
43
break;
44
}
45
// Strip mined loop
46
while (--res > 0) {
47
if (res < 1) {
48
throw new RuntimeException("Should not reach here!");
49
}
50
}
51
52
/*
53
After parsing:
54
Loop:
55
res--;
56
if (res <= 0) {
57
goto End;
58
}
59
if (res < 1) { <- Treated as loop exit check (res <= 0)
60
UncommonTrap();
61
}
62
goto Loop;
63
End:
64
65
Loop opts convert this into:
66
// Outer strip mined loop
67
do {
68
// Strip mined loop
69
do {
70
res--;
71
if (res <= 0) {
72
goto End;
73
}
74
} while (res > 0); <- Always false due to above res <= 0 check
75
Safepoint()
76
} while (false);
77
UncommonTrap();
78
End:
79
80
The safepoint path dies, because the exit condition of the strip mined loop is always false:
81
// Strip mined loop
82
do {
83
res--;
84
if (res <= 0) {
85
goto End;
86
}
87
} while (true);
88
End:
89
*/
90
}
91
return res;
92
}
93
94
public static void main(String[] args) {
95
for (int i = 0; i < 100; i++) {
96
Asserts.assertEQ(test(true), -41);
97
}
98
Asserts.assertEQ(test(false), 5000);
99
}
100
}
101
102