author | tpivovarova |
Tue, 12 Jul 2016 18:24:48 +0300 | |
changeset 40059 | c2304140ed64 |
parent 39422 | 52e7ddc77845 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
23192 | 1 |
/* |
37773
e5b3e9732c3c
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36616
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
23192 | 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. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
/* |
|
27 |
* @test TestStableDouble |
|
28 |
* @summary tests on stable fields and arrays |
|
36508 | 29 |
* @library /testlibrary /test/lib / |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36616
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
36508 | 31 |
* @modules java.base/jdk.internal.vm.annotation |
32 |
* @build sun.hotspot.WhiteBox |
|
33 |
* @build compiler.stable.TestStableDouble |
|
23192 | 34 |
* |
38188
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
35 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
36 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
37 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
38 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
39 |
* compiler.stable.TestStableDouble |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
40 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
41 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
42 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
43 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
44 |
* compiler.stable.TestStableDouble |
23192 | 45 |
* |
38188
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
46 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
47 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
48 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
49 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
50 |
* compiler.stable.TestStableDouble |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
51 |
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
52 |
* -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
53 |
* -XX:-TieredCompilation |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
54 |
* -XX:+FoldStableValues |
e76af590ea2f
8155751: Some tests miss othervm for main/bootclasspath mode
vlivanov
parents:
38152
diff
changeset
|
55 |
* compiler.stable.TestStableDouble |
23192 | 56 |
*/ |
57 |
||
36508 | 58 |
package compiler.stable; |
35099
982950884444
8144223: Move j.l.invoke.{ForceInline, DontInline, Stable} to jdk.internal.vm.annotation package
psandoz
parents:
33730
diff
changeset
|
59 |
|
40059 | 60 |
import jdk.internal.vm.annotation.Stable; |
61 |
||
23192 | 62 |
import java.lang.reflect.InvocationTargetException; |
63 |
||
64 |
public class TestStableDouble { |
|
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
65 |
static final boolean isStableEnabled = StableConfiguration.isStableEnabled; |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
66 |
|
23192 | 67 |
public static void main(String[] args) throws Exception { |
68 |
run(DefaultValue.class); |
|
69 |
run(DoubleStable.class); |
|
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
70 |
run(DefaultStaticValue.class); |
23192 | 71 |
run(StaticDoubleStable.class); |
72 |
run(VolatileDoubleStable.class); |
|
73 |
||
74 |
// @Stable arrays: Dim 1-4 |
|
75 |
run(DoubleArrayDim1.class); |
|
76 |
run(DoubleArrayDim2.class); |
|
77 |
run(DoubleArrayDim3.class); |
|
78 |
run(DoubleArrayDim4.class); |
|
79 |
||
80 |
// @Stable Object field: dynamic arrays |
|
81 |
run(ObjectArrayLowerDim0.class); |
|
82 |
run(ObjectArrayLowerDim1.class); |
|
83 |
run(ObjectArrayLowerDim2.class); |
|
84 |
||
85 |
// Nested @Stable fields |
|
86 |
run(NestedStableField.class); |
|
87 |
run(NestedStableField1.class); |
|
88 |
run(NestedStableField2.class); |
|
89 |
run(NestedStableField3.class); |
|
90 |
||
91 |
if (failed) { |
|
92 |
throw new Error("TEST FAILED"); |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
/* ==================================================== */ |
|
97 |
||
98 |
static class DefaultValue { |
|
99 |
public @Stable double v; |
|
100 |
||
101 |
public static final DefaultValue c = new DefaultValue(); |
|
102 |
public static double get() { return c.v; } |
|
103 |
public static void test() throws Exception { |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
104 |
double val1 = get(); |
23192 | 105 |
c.v = 1.0; double val2 = get(); |
106 |
assertEquals(val1, 0); |
|
107 |
assertEquals(val2, 1.0); |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
/* ==================================================== */ |
|
112 |
||
113 |
static class DoubleStable { |
|
114 |
public @Stable double v; |
|
115 |
||
116 |
public static final DoubleStable c = new DoubleStable(); |
|
117 |
public static double get() { return c.v; } |
|
118 |
public static void test() throws Exception { |
|
119 |
c.v = 1.0; double val1 = get(); |
|
120 |
c.v = Double.MAX_VALUE; double val2 = get(); |
|
121 |
assertEquals(val1, 1.0); |
|
122 |
assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE)); |
|
123 |
} |
|
124 |
} |
|
125 |
||
126 |
/* ==================================================== */ |
|
127 |
||
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
128 |
static class DefaultStaticValue { |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
129 |
public static @Stable double v; |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
130 |
|
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
131 |
public static final DefaultStaticValue c = new DefaultStaticValue(); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
132 |
public static double get() { return c.v; } |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
133 |
public static void test() throws Exception { |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
134 |
double val1 = get(); |
25641
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
135 |
c.v = 1.0; double val2 = get(); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
136 |
assertEquals(val1, 0); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
137 |
assertEquals(val2, 1.0); |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
138 |
} |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
139 |
} |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
140 |
|
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
141 |
/* ==================================================== */ |
d99065e4572b
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
23192
diff
changeset
|
142 |
|
23192 | 143 |
static class StaticDoubleStable { |
144 |
public static @Stable double v; |
|
145 |
||
146 |
public static final StaticDoubleStable c = new StaticDoubleStable(); |
|
147 |
public static double get() { return c.v; } |
|
148 |
public static void test() throws Exception { |
|
149 |
c.v = 1.0; double val1 = get(); |
|
150 |
c.v = Double.MAX_VALUE; double val2 = get(); |
|
151 |
assertEquals(val1, 1.0); |
|
152 |
assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE)); |
|
153 |
} |
|
154 |
} |
|
155 |
||
156 |
/* ==================================================== */ |
|
157 |
||
158 |
static class VolatileDoubleStable { |
|
159 |
public @Stable double v; |
|
160 |
||
161 |
public static final VolatileDoubleStable c = new VolatileDoubleStable(); |
|
162 |
public static double get() { return c.v; } |
|
163 |
public static void test() throws Exception { |
|
164 |
c.v = 1.0; double val1 = get(); |
|
165 |
c.v = Double.MAX_VALUE; double val2 = get(); |
|
166 |
assertEquals(val1, 1.0); |
|
167 |
assertEquals(val2, (isStableEnabled ? 1.0 : Double.MAX_VALUE)); |
|
168 |
} |
|
169 |
} |
|
170 |
||
171 |
/* ==================================================== */ |
|
172 |
// @Stable array == field && all components are stable |
|
173 |
||
174 |
static class DoubleArrayDim1 { |
|
175 |
public @Stable double[] v; |
|
176 |
||
177 |
public static final DoubleArrayDim1 c = new DoubleArrayDim1(); |
|
178 |
public static double get() { return c.v[0]; } |
|
179 |
public static double get1() { return c.v[10]; } |
|
180 |
public static double[] get2() { return c.v; } |
|
181 |
public static void test() throws Exception { |
|
182 |
{ |
|
183 |
c.v = new double[1]; c.v[0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
184 |
c.v[0] = 2.0; double val2 = get(); |
23192 | 185 |
assertEquals(val1, 1.0); |
36604 | 186 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 187 |
|
188 |
c.v = new double[1]; c.v[0] = 3.0; double val3 = get(); |
|
36604 | 189 |
assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
190 |
: 3.0)); |
23192 | 191 |
} |
192 |
||
193 |
{ |
|
194 |
c.v = new double[20]; c.v[10] = 1.0; double val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
195 |
c.v[10] = 2.0; double val2 = get1(); |
23192 | 196 |
assertEquals(val1, 1.0); |
36604 | 197 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 198 |
|
199 |
c.v = new double[20]; c.v[10] = 3.0; double val3 = get1(); |
|
36604 | 200 |
assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
201 |
: 3.0)); |
23192 | 202 |
} |
203 |
||
204 |
{ |
|
205 |
c.v = new double[1]; double[] val1 = get2(); |
|
206 |
c.v = new double[1]; double[] val2 = get2(); |
|
207 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
208 |
} |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
/* ==================================================== */ |
|
213 |
||
214 |
static class DoubleArrayDim2 { |
|
215 |
public @Stable double[][] v; |
|
216 |
||
217 |
public static final DoubleArrayDim2 c = new DoubleArrayDim2(); |
|
218 |
public static double get() { return c.v[0][0]; } |
|
219 |
public static double[] get1() { return c.v[0]; } |
|
220 |
public static double[][] get2() { return c.v; } |
|
221 |
public static void test() throws Exception { |
|
222 |
{ |
|
223 |
c.v = new double[1][1]; c.v[0][0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
224 |
c.v[0][0] = 2.0; double val2 = get(); |
23192 | 225 |
assertEquals(val1, 1.0); |
36604 | 226 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 227 |
|
228 |
c.v = new double[1][1]; c.v[0][0] = 3.0; double val3 = get(); |
|
36604 | 229 |
assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
230 |
: 3.0)); |
23192 | 231 |
|
232 |
c.v[0] = new double[1]; c.v[0][0] = 4.0; double val4 = get(); |
|
36604 | 233 |
assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
234 |
: 4.0)); |
23192 | 235 |
} |
236 |
||
237 |
{ |
|
238 |
c.v = new double[1][1]; double[] val1 = get1(); |
|
239 |
c.v[0] = new double[1]; double[] val2 = get1(); |
|
36604 | 240 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 241 |
} |
242 |
||
243 |
{ |
|
244 |
c.v = new double[1][1]; double[][] val1 = get2(); |
|
245 |
c.v = new double[1][1]; double[][] val2 = get2(); |
|
246 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
/* ==================================================== */ |
|
252 |
||
253 |
static class DoubleArrayDim3 { |
|
254 |
public @Stable double[][][] v; |
|
255 |
||
256 |
public static final DoubleArrayDim3 c = new DoubleArrayDim3(); |
|
257 |
public static double get() { return c.v[0][0][0]; } |
|
258 |
public static double[] get1() { return c.v[0][0]; } |
|
259 |
public static double[][] get2() { return c.v[0]; } |
|
260 |
public static double[][][] get3() { return c.v; } |
|
261 |
public static void test() throws Exception { |
|
262 |
{ |
|
263 |
c.v = new double[1][1][1]; c.v[0][0][0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
264 |
c.v[0][0][0] = 2.0; double val2 = get(); |
23192 | 265 |
assertEquals(val1, 1.0); |
36604 | 266 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 267 |
|
268 |
c.v = new double[1][1][1]; c.v[0][0][0] = 3.0; double val3 = get(); |
|
36604 | 269 |
assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
270 |
: 3.0)); |
23192 | 271 |
|
272 |
c.v[0] = new double[1][1]; c.v[0][0][0] = 4.0; double val4 = get(); |
|
36604 | 273 |
assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
274 |
: 4.0)); |
23192 | 275 |
|
276 |
c.v[0][0] = new double[1]; c.v[0][0][0] = 5.0; double val5 = get(); |
|
36604 | 277 |
assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
278 |
: 5.0)); |
23192 | 279 |
} |
280 |
||
281 |
{ |
|
282 |
c.v = new double[1][1][1]; double[] val1 = get1(); |
|
283 |
c.v[0][0] = new double[1]; double[] val2 = get1(); |
|
36604 | 284 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 285 |
} |
286 |
||
287 |
{ |
|
288 |
c.v = new double[1][1][1]; double[][] val1 = get2(); |
|
289 |
c.v[0] = new double[1][1]; double[][] val2 = get2(); |
|
36604 | 290 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 291 |
} |
292 |
||
293 |
{ |
|
294 |
c.v = new double[1][1][1]; double[][][] val1 = get3(); |
|
295 |
c.v = new double[1][1][1]; double[][][] val2 = get3(); |
|
296 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
297 |
} |
|
298 |
} |
|
299 |
} |
|
300 |
||
301 |
/* ==================================================== */ |
|
302 |
||
303 |
static class DoubleArrayDim4 { |
|
304 |
public @Stable double[][][][] v; |
|
305 |
||
306 |
public static final DoubleArrayDim4 c = new DoubleArrayDim4(); |
|
307 |
public static double get() { return c.v[0][0][0][0]; } |
|
308 |
public static double[] get1() { return c.v[0][0][0]; } |
|
309 |
public static double[][] get2() { return c.v[0][0]; } |
|
310 |
public static double[][][] get3() { return c.v[0]; } |
|
311 |
public static double[][][][] get4() { return c.v; } |
|
312 |
public static void test() throws Exception { |
|
313 |
{ |
|
314 |
c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
315 |
c.v[0][0][0][0] = 2.0; double val2 = get(); |
23192 | 316 |
assertEquals(val1, 1.0); |
36604 | 317 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 318 |
|
319 |
c.v = new double[1][1][1][1]; c.v[0][0][0][0] = 3.0; double val3 = get(); |
|
36604 | 320 |
assertEquals(val3, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
321 |
: 3.0)); |
23192 | 322 |
|
323 |
c.v[0] = new double[1][1][1]; c.v[0][0][0][0] = 4.0; double val4 = get(); |
|
36604 | 324 |
assertEquals(val4, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
325 |
: 4.0)); |
23192 | 326 |
|
327 |
c.v[0][0] = new double[1][1]; c.v[0][0][0][0] = 5.0; double val5 = get(); |
|
36604 | 328 |
assertEquals(val5, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
329 |
: 5.0)); |
23192 | 330 |
|
331 |
c.v[0][0][0] = new double[1]; c.v[0][0][0][0] = 6.0; double val6 = get(); |
|
36604 | 332 |
assertEquals(val6, (isStableEnabled ? (isStableEnabled ? 1.0 : 2.0) |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
333 |
: 6.0)); |
23192 | 334 |
} |
335 |
||
336 |
{ |
|
337 |
c.v = new double[1][1][1][1]; double[] val1 = get1(); |
|
338 |
c.v[0][0][0] = new double[1]; double[] val2 = get1(); |
|
36604 | 339 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 340 |
} |
341 |
||
342 |
{ |
|
343 |
c.v = new double[1][1][1][1]; double[][] val1 = get2(); |
|
344 |
c.v[0][0] = new double[1][1]; double[][] val2 = get2(); |
|
36604 | 345 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 346 |
} |
347 |
||
348 |
{ |
|
349 |
c.v = new double[1][1][1][1]; double[][][] val1 = get3(); |
|
350 |
c.v[0] = new double[1][1][1]; double[][][] val2 = get3(); |
|
36604 | 351 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 352 |
} |
353 |
||
354 |
{ |
|
355 |
c.v = new double[1][1][1][1]; double[][][][] val1 = get4(); |
|
356 |
c.v = new double[1][1][1][1]; double[][][][] val2 = get4(); |
|
357 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
358 |
} |
|
359 |
} |
|
360 |
} |
|
361 |
||
362 |
/* ==================================================== */ |
|
363 |
// Dynamic Dim is higher than static |
|
364 |
static class ObjectArrayLowerDim0 { |
|
365 |
public @Stable Object v; |
|
366 |
||
367 |
public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0(); |
|
368 |
public static double get() { return ((double[])c.v)[0]; } |
|
369 |
public static double[] get1() { return (double[])c.v; } |
|
370 |
||
371 |
public static void test() throws Exception { |
|
372 |
{ |
|
373 |
c.v = new double[1]; ((double[])c.v)[0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
374 |
((double[])c.v)[0] = 2.0; double val2 = get(); |
23192 | 375 |
|
376 |
assertEquals(val1, 1.0); |
|
377 |
assertEquals(val2, 2.0); |
|
378 |
} |
|
379 |
||
380 |
{ |
|
381 |
c.v = new double[1]; double[] val1 = get1(); |
|
382 |
c.v = new double[1]; double[] val2 = get1(); |
|
383 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
384 |
} |
|
385 |
} |
|
386 |
} |
|
387 |
||
388 |
/* ==================================================== */ |
|
389 |
||
390 |
static class ObjectArrayLowerDim1 { |
|
391 |
public @Stable Object[] v; |
|
392 |
||
393 |
public static final ObjectArrayLowerDim1 c = new ObjectArrayLowerDim1(); |
|
394 |
public static double get() { return ((double[][])c.v)[0][0]; } |
|
395 |
public static double[] get1() { return (double[])(c.v[0]); } |
|
396 |
public static Object[] get2() { return c.v; } |
|
397 |
||
398 |
public static void test() throws Exception { |
|
399 |
{ |
|
400 |
c.v = new double[1][1]; ((double[][])c.v)[0][0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
401 |
((double[][])c.v)[0][0] = 2.0; double val2 = get(); |
23192 | 402 |
|
403 |
assertEquals(val1, 1.0); |
|
404 |
assertEquals(val2, 2.0); |
|
405 |
} |
|
406 |
||
407 |
{ |
|
408 |
c.v = new double[1][1]; c.v[0] = new double[0]; double[] val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
409 |
c.v[0] = new double[0]; double[] val2 = get1(); |
23192 | 410 |
|
36604 | 411 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 412 |
} |
413 |
||
414 |
{ |
|
415 |
c.v = new double[0][0]; Object[] val1 = get2(); |
|
416 |
c.v = new double[0][0]; Object[] val2 = get2(); |
|
417 |
||
418 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
419 |
} |
|
420 |
} |
|
421 |
} |
|
422 |
||
423 |
/* ==================================================== */ |
|
424 |
||
425 |
static class ObjectArrayLowerDim2 { |
|
426 |
public @Stable Object[][] v; |
|
427 |
||
428 |
public static final ObjectArrayLowerDim2 c = new ObjectArrayLowerDim2(); |
|
429 |
public static double get() { return ((double[][][])c.v)[0][0][0]; } |
|
430 |
public static double[] get1() { return (double[])(c.v[0][0]); } |
|
431 |
public static double[][] get2() { return (double[][])(c.v[0]); } |
|
432 |
public static Object[][] get3() { return c.v; } |
|
433 |
||
434 |
public static void test() throws Exception { |
|
435 |
{ |
|
436 |
c.v = new double[1][1][1]; ((double[][][])c.v)[0][0][0] = 1.0; double val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
437 |
((double[][][])c.v)[0][0][0] = 2.0; double val2 = get(); |
23192 | 438 |
|
439 |
assertEquals(val1, 1.0); |
|
440 |
assertEquals(val2, 2.0); |
|
441 |
} |
|
442 |
||
443 |
{ |
|
444 |
c.v = new double[1][1][1]; c.v[0][0] = new double[0]; double[] val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
445 |
c.v[0][0] = new double[0]; double[] val2 = get1(); |
23192 | 446 |
|
36604 | 447 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 448 |
} |
449 |
||
450 |
{ |
|
451 |
c.v = new double[1][1][1]; c.v[0] = new double[0][0]; double[][] val1 = get2(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
452 |
c.v[0] = new double[0][0]; double[][] val2 = get2(); |
23192 | 453 |
|
36604 | 454 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
23192 | 455 |
} |
456 |
||
457 |
{ |
|
458 |
c.v = new double[0][0][0]; Object[][] val1 = get3(); |
|
459 |
c.v = new double[0][0][0]; Object[][] val2 = get3(); |
|
460 |
||
461 |
assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
|
462 |
} |
|
463 |
} |
|
464 |
} |
|
465 |
||
466 |
/* ==================================================== */ |
|
467 |
||
468 |
static class NestedStableField { |
|
469 |
static class A { |
|
470 |
public @Stable double a; |
|
471 |
||
472 |
} |
|
473 |
public @Stable A v; |
|
474 |
||
475 |
public static final NestedStableField c = new NestedStableField(); |
|
476 |
public static A get() { return c.v; } |
|
477 |
public static double get1() { return get().a; } |
|
478 |
||
479 |
public static void test() throws Exception { |
|
480 |
{ |
|
481 |
c.v = new A(); c.v.a = 1.0; A val1 = get(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
482 |
c.v.a = 2.0; A val2 = get(); |
23192 | 483 |
|
484 |
assertEquals(val1.a, 2.0); |
|
485 |
assertEquals(val2.a, 2.0); |
|
486 |
} |
|
487 |
||
488 |
{ |
|
489 |
c.v = new A(); c.v.a = 1.0; double val1 = get1(); |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
490 |
c.v.a = 2.0; double val2 = get1(); |
23192 | 491 |
c.v = new A(); c.v.a = 3.0; double val3 = get1(); |
492 |
||
493 |
assertEquals(val1, 1.0); |
|
494 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
|
495 |
assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); |
|
496 |
} |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
/* ==================================================== */ |
|
501 |
||
502 |
static class NestedStableField1 { |
|
503 |
static class A { |
|
504 |
public @Stable double a; |
|
505 |
public @Stable A next; |
|
506 |
} |
|
507 |
public @Stable A v; |
|
508 |
||
509 |
public static final NestedStableField1 c = new NestedStableField1(); |
|
510 |
public static A get() { return c.v.next.next.next.next.next.next.next; } |
|
511 |
public static double get1() { return get().a; } |
|
512 |
||
513 |
public static void test() throws Exception { |
|
514 |
{ |
|
515 |
c.v = new A(); c.v.next = new A(); c.v.next.next = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
516 |
c.v.a = 1.0; c.v.next.a = 1.0; A val1 = get(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
517 |
c.v.a = 2.0; c.v.next.a = 2.0; A val2 = get(); |
23192 | 518 |
|
519 |
assertEquals(val1.a, 2.0); |
|
520 |
assertEquals(val2.a, 2.0); |
|
521 |
} |
|
522 |
||
523 |
{ |
|
524 |
c.v = new A(); c.v.next = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
525 |
c.v.a = 1.0; double val1 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
526 |
c.v.a = 2.0; double val2 = get1(); |
23192 | 527 |
c.v = new A(); c.v.next = c.v; |
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
528 |
c.v.a = 3.0; double val3 = get1(); |
23192 | 529 |
|
530 |
assertEquals(val1, 1.0); |
|
531 |
assertEquals(val2, (isStableEnabled ? 1.0 : 2.0)); |
|
532 |
assertEquals(val3, (isStableEnabled ? 1.0 : 3.0)); |
|
533 |
} |
|
534 |
} |
|
535 |
} |
|
536 |
/* ==================================================== */ |
|
537 |
||
538 |
static class NestedStableField2 { |
|
539 |
static class A { |
|
540 |
public @Stable double a; |
|
541 |
public @Stable A left; |
|
542 |
public A right; |
|
543 |
} |
|
544 |
||
545 |
public @Stable A v; |
|
546 |
||
547 |
public static final NestedStableField2 c = new NestedStableField2(); |
|
548 |
public static double get() { return c.v.left.left.left.a; } |
|
549 |
public static double get1() { return c.v.left.left.right.left.a; } |
|
550 |
||
551 |
public static void test() throws Exception { |
|
552 |
{ |
|
553 |
c.v = new A(); c.v.left = c.v.right = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
554 |
c.v.a = 1.0; double val1 = get(); double val2 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
555 |
c.v.a = 2.0; double val3 = get(); double val4 = get1(); |
23192 | 556 |
|
557 |
assertEquals(val1, 1.0); |
|
558 |
assertEquals(val3, (isStableEnabled ? 1.0 : 2.0)); |
|
559 |
||
560 |
assertEquals(val2, 1.0); |
|
561 |
assertEquals(val4, 2.0); |
|
562 |
} |
|
563 |
} |
|
564 |
} |
|
565 |
||
566 |
/* ==================================================== */ |
|
567 |
||
568 |
static class NestedStableField3 { |
|
569 |
static class A { |
|
570 |
public @Stable double a; |
|
571 |
public @Stable A[] left; |
|
572 |
public A[] right; |
|
573 |
} |
|
574 |
||
575 |
public @Stable A[] v; |
|
576 |
||
577 |
public static final NestedStableField3 c = new NestedStableField3(); |
|
578 |
public static double get() { return c.v[0].left[1].left[0].left[1].a; } |
|
579 |
public static double get1() { return c.v[1].left[0].left[1].right[0].left[1].a; } |
|
580 |
||
581 |
public static void test() throws Exception { |
|
582 |
{ |
|
583 |
A elem = new A(); |
|
584 |
c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; |
|
39422
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
585 |
elem.a = 1.0; double val1 = get(); double val2 = get1(); |
52e7ddc77845
8149043: Fix code indentation in test/compiler/stable tests
iignatyev
parents:
38207
diff
changeset
|
586 |
elem.a = 2.0; double val3 = get(); double val4 = get1(); |
23192 | 587 |
|
588 |
assertEquals(val1, 1.0); |
|
36604 | 589 |
assertEquals(val3, (isStableEnabled ? 1.0 : 2.0)); |
23192 | 590 |
|
591 |
assertEquals(val2, 1.0); |
|
592 |
assertEquals(val4, 2.0); |
|
593 |
} |
|
594 |
} |
|
595 |
} |
|
596 |
||
597 |
/* ==================================================== */ |
|
598 |
// Auxiliary methods |
|
599 |
static void assertEquals(double i, double j) { if (i != j) throw new AssertionError(i + " != " + j); } |
|
600 |
static void assertTrue(boolean b) { if (!b) throw new AssertionError(); } |
|
601 |
||
602 |
static boolean failed = false; |
|
603 |
||
604 |
public static void run(Class<?> test) { |
|
605 |
Throwable ex = null; |
|
606 |
System.out.print(test.getName()+": "); |
|
607 |
try { |
|
608 |
test.getMethod("test").invoke(null); |
|
609 |
} catch (InvocationTargetException e) { |
|
610 |
ex = e.getCause(); |
|
611 |
} catch (Throwable e) { |
|
612 |
ex = e; |
|
613 |
} finally { |
|
614 |
if (ex == null) { |
|
615 |
System.out.println("PASSED"); |
|
616 |
} else { |
|
617 |
failed = true; |
|
618 |
System.out.println("FAILED"); |
|
619 |
ex.printStackTrace(System.out); |
|
620 |
} |
|
621 |
} |
|
622 |
} |
|
623 |
} |