Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/c1/CanonicalizeArrayLength.java
41152 views
1
/*
2
* Copyright (c) 2017, 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 8150102 8150514 8150534 8171435
27
* @summary C1 crashes in Canonicalizer::do_ArrayLength() after fix for JDK-8150102
28
*
29
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
30
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
31
* -XX:-BackgroundCompilation
32
* compiler.c1.CanonicalizeArrayLength
33
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
34
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=3
35
* -XX:-BackgroundCompilation
36
* -XX:+PatchALot
37
* compiler.c1.CanonicalizeArrayLength
38
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
39
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
40
* -XX:-BackgroundCompilation
41
* -XX:ScavengeRootsInCode=0
42
* compiler.c1.CanonicalizeArrayLength
43
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
44
* -XX:CompileThreshold=100 -XX:+TieredCompilation -XX:TieredStopAtLevel=1
45
* -XX:-BackgroundCompilation -XX:ScavengeRootsInCode=1
46
* compiler.c1.CanonicalizeArrayLength
47
*/
48
49
package compiler.c1;
50
51
public class CanonicalizeArrayLength {
52
int[] arr = new int[42];
53
int[] arrNull = null;
54
55
final int[] finalArr = new int[42];
56
final int[] finalArrNull = null;
57
58
static int[] staticArr = new int[42];
59
static int[] staticArrNull = null;
60
61
static final int[] staticFinalArr = new int[42];
62
static final int[] staticFinalArrNull = null;
63
64
public static void main(String... args) {
65
CanonicalizeArrayLength t = new CanonicalizeArrayLength();
66
for (int i = 0; i < 20000; i++) {
67
if (t.testLocal() != 42)
68
throw new IllegalStateException();
69
if (t.testLocalNull() != 42)
70
throw new IllegalStateException();
71
if (t.testField() != 42)
72
throw new IllegalStateException();
73
if (t.testFieldNull() != 42)
74
throw new IllegalStateException();
75
if (t.testFinalField() != 42)
76
throw new IllegalStateException();
77
if (t.testFinalFieldNull() != 42)
78
throw new IllegalStateException();
79
if (t.testStaticField() != 42)
80
throw new IllegalStateException();
81
if (t.testStaticFieldNull() != 42)
82
throw new IllegalStateException();
83
if (t.testStaticFinalField() != 42)
84
throw new IllegalStateException();
85
if (t.testStaticFinalFieldNull() != 42)
86
throw new IllegalStateException();
87
}
88
}
89
90
int testField() {
91
try {
92
return arr.length;
93
} catch (Throwable t) {
94
return -1;
95
}
96
}
97
98
int testFieldNull() {
99
try {
100
return arrNull.length;
101
} catch (Throwable t) {
102
return 42;
103
}
104
}
105
106
int testFinalField() {
107
try {
108
return finalArr.length;
109
} catch (Throwable t) {
110
return -1;
111
}
112
}
113
114
int testFinalFieldNull() {
115
try {
116
return finalArrNull.length;
117
} catch (Throwable t) {
118
return 42;
119
}
120
}
121
122
int testStaticField() {
123
try {
124
return staticArr.length;
125
} catch (Throwable t) {
126
return -1;
127
}
128
}
129
130
int testStaticFieldNull() {
131
try {
132
return staticArrNull.length;
133
} catch (Throwable t) {
134
return 42;
135
}
136
}
137
138
int testStaticFinalField() {
139
try {
140
return staticFinalArr.length;
141
} catch (Throwable t) {
142
return -1;
143
}
144
}
145
146
int testStaticFinalFieldNull() {
147
try {
148
return staticFinalArrNull.length;
149
} catch (Throwable t) {
150
return 42;
151
}
152
}
153
154
int testLocal() {
155
int[] arr = new int[42];
156
try {
157
return arr.length;
158
} catch (Throwable t) {
159
return -1;
160
}
161
}
162
163
int testLocalNull() {
164
int[] arrNull = null;
165
try {
166
return arrNull.length;
167
} catch (Throwable t) {
168
return 42;
169
}
170
}
171
172
173
}
174
175