Mercurial > hg > graal-jvmci-8
comparison test/compiler/stable/TestStableObject.java @ 18004:ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
Reviewed-by: kvn, jrose
author | vlivanov |
---|---|
date | Thu, 10 Jul 2014 12:04:43 -0700 |
parents | 248ff38d2950 |
children | 1ec24746bb40 |
comparison
equal
deleted
inserted
replaced
18003:dda2ae6f9557 | 18004:ee1c924763d2 |
---|---|
24 */ | 24 */ |
25 | 25 |
26 /* | 26 /* |
27 * @test TestStableObject | 27 * @test TestStableObject |
28 * @summary tests on stable fields and arrays | 28 * @summary tests on stable fields and arrays |
29 * @library /testlibrary | 29 * @library /testlibrary /testlibrary/whitebox |
30 * @compile -XDignore.symbol.file TestStableObject.java | 30 * @build TestStableObject StableConfiguration sun.hotspot.WhiteBox |
31 * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission | |
31 * @run main ClassFileInstaller | 32 * @run main ClassFileInstaller |
33 * java/lang/invoke/StableConfiguration | |
32 * java/lang/invoke/TestStableObject | 34 * java/lang/invoke/TestStableObject |
33 * java/lang/invoke/TestStableObject$ObjectStable | 35 * java/lang/invoke/TestStableObject$ObjectStable |
34 * java/lang/invoke/TestStableObject$StaticObjectStable | 36 * java/lang/invoke/TestStableObject$StaticObjectStable |
35 * java/lang/invoke/TestStableObject$VolatileObjectStable | 37 * java/lang/invoke/TestStableObject$VolatileObjectStable |
36 * java/lang/invoke/TestStableObject$ObjectArrayDim1 | 38 * java/lang/invoke/TestStableObject$ObjectArrayDim1 |
47 * java/lang/invoke/TestStableObject$NestedStableField2$A | 49 * java/lang/invoke/TestStableObject$NestedStableField2$A |
48 * java/lang/invoke/TestStableObject$NestedStableField3 | 50 * java/lang/invoke/TestStableObject$NestedStableField3 |
49 * java/lang/invoke/TestStableObject$NestedStableField3$A | 51 * java/lang/invoke/TestStableObject$NestedStableField3$A |
50 * java/lang/invoke/TestStableObject$Values | 52 * java/lang/invoke/TestStableObject$Values |
51 * java/lang/invoke/TestStableObject$DefaultValue | 53 * java/lang/invoke/TestStableObject$DefaultValue |
54 * java/lang/invoke/TestStableObject$DefaultStaticValue | |
52 * java/lang/invoke/TestStableObject$ObjectArrayLowerDim2 | 55 * java/lang/invoke/TestStableObject$ObjectArrayLowerDim2 |
53 * | 56 * |
54 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | 57 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions |
55 * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:+UseCompressedOop | 58 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
56 * -server -XX:-TieredCompilation -Xcomp | 59 * -server -XX:-TieredCompilation |
60 * -XX:+FoldStableValues | |
61 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | |
62 * java.lang.invoke.TestStableObject | |
63 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | |
64 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp | |
65 * -server -XX:-TieredCompilation | |
66 * -XX:-FoldStableValues | |
57 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | 67 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
58 * java.lang.invoke.TestStableObject | 68 * java.lang.invoke.TestStableObject |
59 * | 69 * |
60 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | 70 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions |
61 * -XX:+UnlockDiagnosticVMOptions -XX:+FoldStableValues -XX:-UseCompressedOop | 71 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
62 * -server -XX:-TieredCompilation -Xcomp | 72 * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 |
73 * -XX:+FoldStableValues | |
74 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | |
75 * java.lang.invoke.TestStableObject | |
76 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | |
77 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp | |
78 * -server -XX:+TieredCompilation -XX:TieredStopAtLevel=1 | |
79 * -XX:-FoldStableValues | |
63 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | 80 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
64 * java.lang.invoke.TestStableObject | 81 * java.lang.invoke.TestStableObject |
65 * | 82 * |
66 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | 83 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions |
67 * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:+UseCompressedOop | 84 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
68 * -server -XX:-TieredCompilation -Xcomp | 85 * -client -XX:-TieredCompilation |
86 * -XX:+FoldStableValues | |
69 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | 87 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
70 * java.lang.invoke.TestStableObject | 88 * java.lang.invoke.TestStableObject |
71 * | |
72 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions | 89 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions |
73 * -XX:+UnlockDiagnosticVMOptions -XX:-FoldStableValues -XX:-UseCompressedOop | 90 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp |
74 * -server -XX:-TieredCompilation -Xcomp | 91 * -client -XX:-TieredCompilation |
92 * -XX:-FoldStableValues | |
75 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 | 93 * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 |
76 * java.lang.invoke.TestStableObject | 94 * java.lang.invoke.TestStableObject |
77 */ | 95 */ |
78 package java.lang.invoke; | 96 package java.lang.invoke; |
79 | 97 |
80 import com.sun.management.HotSpotDiagnosticMXBean; | |
81 import com.sun.management.VMOption; | |
82 import sun.management.ManagementFactoryHelper; | |
83 import java.lang.reflect.InvocationTargetException; | 98 import java.lang.reflect.InvocationTargetException; |
84 | 99 |
85 public class TestStableObject { | 100 public class TestStableObject { |
101 static final boolean isStableEnabled = StableConfiguration.isStableEnabled; | |
102 static final boolean isServerWithStable = StableConfiguration.isServerWithStable; | |
103 | |
86 public static void main(String[] args) throws Exception { | 104 public static void main(String[] args) throws Exception { |
87 System.out.println("@Stable enabled: "+isStableEnabled); | |
88 System.out.println(); | |
89 | |
90 run(DefaultValue.class); | 105 run(DefaultValue.class); |
91 run(ObjectStable.class); | 106 run(ObjectStable.class); |
107 run(DefaultStaticValue.class); | |
92 run(StaticObjectStable.class); | 108 run(StaticObjectStable.class); |
93 run(VolatileObjectStable.class); | 109 run(VolatileObjectStable.class); |
94 | 110 |
95 // @Stable arrays: Dim 1-4 | 111 // @Stable arrays: Dim 1-4 |
96 run(ObjectArrayDim1.class); | 112 run(ObjectArrayDim1.class); |
146 } | 162 } |
147 } | 163 } |
148 | 164 |
149 /* ==================================================== */ | 165 /* ==================================================== */ |
150 | 166 |
167 static class DefaultStaticValue { | |
168 public static @Stable Object v; | |
169 | |
170 public static final DefaultStaticValue c = new DefaultStaticValue(); | |
171 public static Object get() { return c.v; } | |
172 public static void test() throws Exception { | |
173 Object val1 = get(); | |
174 c.v = Values.A; Object val2 = get(); | |
175 assertEquals(val1, null); | |
176 assertEquals(val2, Values.A); | |
177 } | |
178 } | |
179 | |
180 /* ==================================================== */ | |
181 | |
151 static class StaticObjectStable { | 182 static class StaticObjectStable { |
152 public static @Stable Values v; | 183 public static @Stable Values v; |
153 | 184 |
154 public static final ObjectStable c = new ObjectStable (); | 185 public static final ObjectStable c = new ObjectStable (); |
155 public static Values get() { return c.v; } | 186 public static Values get() { return c.v; } |
189 public static void test() throws Exception { | 220 public static void test() throws Exception { |
190 { | 221 { |
191 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get(); | 222 c.v = new Object[1]; c.v[0] = Values.A; Object val1 = get(); |
192 c.v[0] = Values.B; Object val2 = get(); | 223 c.v[0] = Values.B; Object val2 = get(); |
193 assertEquals(val1, Values.A); | 224 assertEquals(val1, Values.A); |
194 assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); | 225 assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); |
195 | 226 |
196 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get(); | 227 c.v = new Object[1]; c.v[0] = Values.C; Object val3 = get(); |
197 assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); | 228 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
229 : Values.C)); | |
198 } | 230 } |
199 | 231 |
200 { | 232 { |
201 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1(); | 233 c.v = new Object[20]; c.v[10] = Values.A; Object val1 = get1(); |
202 c.v[10] = Values.B; Object val2 = get1(); | 234 c.v[10] = Values.B; Object val2 = get1(); |
203 assertEquals(val1, Values.A); | 235 assertEquals(val1, Values.A); |
204 assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); | 236 assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); |
205 | 237 |
206 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1(); | 238 c.v = new Object[20]; c.v[10] = Values.C; Object val3 = get1(); |
207 assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); | 239 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
240 : Values.C)); | |
208 } | 241 } |
209 | 242 |
210 { | 243 { |
211 c.v = new Object[1]; Object[] val1 = get2(); | 244 c.v = new Object[1]; Object[] val1 = get2(); |
212 c.v = new Object[1]; Object[] val2 = get2(); | 245 c.v = new Object[1]; Object[] val2 = get2(); |
227 public static void test() throws Exception { | 260 public static void test() throws Exception { |
228 { | 261 { |
229 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get(); | 262 c.v = new Object[1][1]; c.v[0][0] = Values.A; Object val1 = get(); |
230 c.v[0][0] = Values.B; Object val2 = get(); | 263 c.v[0][0] = Values.B; Object val2 = get(); |
231 assertEquals(val1, Values.A); | 264 assertEquals(val1, Values.A); |
232 assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); | 265 assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); |
233 | 266 |
234 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get(); | 267 c.v = new Object[1][1]; c.v[0][0] = Values.C; Object val3 = get(); |
235 assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); | 268 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
269 : Values.C)); | |
236 | 270 |
237 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get(); | 271 c.v[0] = new Object[1]; c.v[0][0] = Values.D; Object val4 = get(); |
238 assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); | 272 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
273 : Values.D)); | |
239 } | 274 } |
240 | 275 |
241 { | 276 { |
242 c.v = new Object[1][1]; Object[] val1 = get1(); | 277 c.v = new Object[1][1]; Object[] val1 = get1(); |
243 c.v[0] = new Object[1]; Object[] val2 = get1(); | 278 c.v[0] = new Object[1]; Object[] val2 = get1(); |
244 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 279 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
245 } | 280 } |
246 | 281 |
247 { | 282 { |
248 c.v = new Object[1][1]; Object[][] val1 = get2(); | 283 c.v = new Object[1][1]; Object[][] val1 = get2(); |
249 c.v = new Object[1][1]; Object[][] val2 = get2(); | 284 c.v = new Object[1][1]; Object[][] val2 = get2(); |
265 public static void test() throws Exception { | 300 public static void test() throws Exception { |
266 { | 301 { |
267 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get(); | 302 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.A; Object val1 = get(); |
268 c.v[0][0][0] = Values.B; Object val2 = get(); | 303 c.v[0][0][0] = Values.B; Object val2 = get(); |
269 assertEquals(val1, Values.A); | 304 assertEquals(val1, Values.A); |
270 assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); | 305 assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); |
271 | 306 |
272 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get(); | 307 c.v = new Object[1][1][1]; c.v[0][0][0] = Values.C; Object val3 = get(); |
273 assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); | 308 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
309 : Values.C)); | |
274 | 310 |
275 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get(); | 311 c.v[0] = new Object[1][1]; c.v[0][0][0] = Values.D; Object val4 = get(); |
276 assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); | 312 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
313 : Values.D)); | |
277 | 314 |
278 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get(); | 315 c.v[0][0] = new Object[1]; c.v[0][0][0] = Values.E; Object val5 = get(); |
279 assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); | 316 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
317 : Values.E)); | |
280 } | 318 } |
281 | 319 |
282 { | 320 { |
283 c.v = new Object[1][1][1]; Object[] val1 = get1(); | 321 c.v = new Object[1][1][1]; Object[] val1 = get1(); |
284 c.v[0][0] = new Object[1]; Object[] val2 = get1(); | 322 c.v[0][0] = new Object[1]; Object[] val2 = get1(); |
285 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 323 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
286 } | 324 } |
287 | 325 |
288 { | 326 { |
289 c.v = new Object[1][1][1]; Object[][] val1 = get2(); | 327 c.v = new Object[1][1][1]; Object[][] val1 = get2(); |
290 c.v[0] = new Object[1][1]; Object[][] val2 = get2(); | 328 c.v[0] = new Object[1][1]; Object[][] val2 = get2(); |
291 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 329 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
292 } | 330 } |
293 | 331 |
294 { | 332 { |
295 c.v = new Object[1][1][1]; Object[][][] val1 = get3(); | 333 c.v = new Object[1][1][1]; Object[][][] val1 = get3(); |
296 c.v = new Object[1][1][1]; Object[][][] val2 = get3(); | 334 c.v = new Object[1][1][1]; Object[][][] val2 = get3(); |
313 public static void test() throws Exception { | 351 public static void test() throws Exception { |
314 { | 352 { |
315 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get(); | 353 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.A; Object val1 = get(); |
316 c.v[0][0][0][0] = Values.B; Object val2 = get(); | 354 c.v[0][0][0][0] = Values.B; Object val2 = get(); |
317 assertEquals(val1, Values.A); | 355 assertEquals(val1, Values.A); |
318 assertEquals(val2, (isStableEnabled ? Values.A : Values.B)); | 356 assertEquals(val2, (isServerWithStable ? Values.A : Values.B)); |
319 | 357 |
320 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get(); | 358 c.v = new Object[1][1][1][1]; c.v[0][0][0][0] = Values.C; Object val3 = get(); |
321 assertEquals(val3, (isStableEnabled ? Values.A : Values.C)); | 359 assertEquals(val3, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
360 : Values.C)); | |
322 | 361 |
323 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get(); | 362 c.v[0] = new Object[1][1][1]; c.v[0][0][0][0] = Values.D; Object val4 = get(); |
324 assertEquals(val4, (isStableEnabled ? Values.A : Values.D)); | 363 assertEquals(val4, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
364 : Values.D)); | |
325 | 365 |
326 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get(); | 366 c.v[0][0] = new Object[1][1]; c.v[0][0][0][0] = Values.E; Object val5 = get(); |
327 assertEquals(val5, (isStableEnabled ? Values.A : Values.E)); | 367 assertEquals(val5, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
368 : Values.E)); | |
328 | 369 |
329 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get(); | 370 c.v[0][0][0] = new Object[1]; c.v[0][0][0][0] = Values.F; Object val6 = get(); |
330 assertEquals(val6, (isStableEnabled ? Values.A : Values.F)); | 371 assertEquals(val6, (isStableEnabled ? (isServerWithStable ? Values.A : Values.B) |
372 : Values.F)); | |
331 } | 373 } |
332 | 374 |
333 { | 375 { |
334 c.v = new Object[1][1][1][1]; Object[] val1 = get1(); | 376 c.v = new Object[1][1][1][1]; Object[] val1 = get1(); |
335 c.v[0][0][0] = new Object[1]; Object[] val2 = get1(); | 377 c.v[0][0][0] = new Object[1]; Object[] val2 = get1(); |
336 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 378 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
337 } | 379 } |
338 | 380 |
339 { | 381 { |
340 c.v = new Object[1][1][1][1]; Object[][] val1 = get2(); | 382 c.v = new Object[1][1][1][1]; Object[][] val1 = get2(); |
341 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2(); | 383 c.v[0][0] = new Object[1][1]; Object[][] val2 = get2(); |
342 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 384 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
343 } | 385 } |
344 | 386 |
345 { | 387 { |
346 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3(); | 388 c.v = new Object[1][1][1][1]; Object[][][] val1 = get3(); |
347 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3(); | 389 c.v[0] = new Object[1][1][1]; Object[][][] val2 = get3(); |
348 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 390 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
349 } | 391 } |
350 | 392 |
351 { | 393 { |
352 c.v = new Object[1][1][1][1]; Object[][][][] val1 = get4(); | 394 c.v = new Object[1][1][1][1]; Object[][][][] val1 = get4(); |
353 c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4(); | 395 c.v = new Object[1][1][1][1]; Object[][][][] val2 = get4(); |
354 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 396 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); |
355 } | 397 } |
356 | |
357 } | 398 } |
358 } | 399 } |
359 | 400 |
360 /* ==================================================== */ | 401 /* ==================================================== */ |
361 // Dynamic Dim is higher than static | 402 // Dynamic Dim is higher than static |
362 | |
363 static class ObjectArrayLowerDim0 { | 403 static class ObjectArrayLowerDim0 { |
364 public @Stable Object v; | 404 public @Stable Object v; |
365 | 405 |
366 public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0(); | 406 public static final ObjectArrayLowerDim0 c = new ObjectArrayLowerDim0(); |
367 public static Object get() { return ((Object[])c.v)[0]; } | 407 public static Object get() { return ((Object[])c.v)[0]; } |
405 | 445 |
406 { | 446 { |
407 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1(); | 447 c.v = new Object[1][1]; c.v[0] = new Object[0]; Object[] val1 = get1(); |
408 c.v[0] = new Object[0]; Object[] val2 = get1(); | 448 c.v[0] = new Object[0]; Object[] val2 = get1(); |
409 | 449 |
410 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 450 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
411 } | 451 } |
412 | 452 |
413 { | 453 { |
414 c.v = new Object[0][0]; Object[] val1 = get2(); | 454 c.v = new Object[0][0]; Object[] val1 = get2(); |
415 c.v = new Object[0][0]; Object[] val2 = get2(); | 455 c.v = new Object[0][0]; Object[] val2 = get2(); |
441 | 481 |
442 { | 482 { |
443 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1(); | 483 c.v = new Object[1][1][1]; c.v[0][0] = new Object[0]; Object[] val1 = get1(); |
444 c.v[0][0] = new Object[0]; Object[] val2 = get1(); | 484 c.v[0][0] = new Object[0]; Object[] val2 = get1(); |
445 | 485 |
446 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 486 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
447 } | 487 } |
448 | 488 |
449 { | 489 { |
450 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2(); | 490 c.v = new Object[1][1][1]; c.v[0] = new Object[0][0]; Object[][] val1 = get2(); |
451 c.v[0] = new Object[0][0]; Object[][] val2 = get2(); | 491 c.v[0] = new Object[0][0]; Object[][] val2 = get2(); |
452 | 492 |
453 assertTrue((isStableEnabled ? (val1 == val2) : (val1 != val2))); | 493 assertTrue((isServerWithStable ? (val1 == val2) : (val1 != val2))); |
454 } | 494 } |
455 | 495 |
456 { | 496 { |
457 c.v = new Object[0][0][0]; Object[][] val1 = get3(); | 497 c.v = new Object[0][0][0]; Object[][] val1 = get3(); |
458 c.v = new Object[0][0][0]; Object[][] val2 = get3(); | 498 c.v = new Object[0][0][0]; Object[][] val2 = get3(); |
583 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; | 623 c.v = new A[] { elem, elem }; c.v[0].left = c.v[0].right = c.v; |
584 elem.a = Values.A; Object val1 = get(); Object val2 = get1(); | 624 elem.a = Values.A; Object val1 = get(); Object val2 = get1(); |
585 elem.a = Values.B; Object val3 = get(); Object val4 = get1(); | 625 elem.a = Values.B; Object val3 = get(); Object val4 = get1(); |
586 | 626 |
587 assertEquals(val1, Values.A); | 627 assertEquals(val1, Values.A); |
588 assertEquals(val3, (isStableEnabled ? Values.A : Values.B)); | 628 assertEquals(val3, (isServerWithStable ? Values.A : Values.B)); |
589 | 629 |
590 assertEquals(val2, Values.A); | 630 assertEquals(val2, Values.A); |
591 assertEquals(val4, Values.B); | 631 assertEquals(val4, Values.B); |
592 } | 632 } |
593 } | 633 } |
617 System.out.println("FAILED"); | 657 System.out.println("FAILED"); |
618 ex.printStackTrace(System.out); | 658 ex.printStackTrace(System.out); |
619 } | 659 } |
620 } | 660 } |
621 } | 661 } |
622 | |
623 static final boolean isStableEnabled; | |
624 static { | |
625 HotSpotDiagnosticMXBean diagnostic | |
626 = ManagementFactoryHelper.getDiagnosticMXBean(); | |
627 VMOption tmp; | |
628 try { | |
629 tmp = diagnostic.getVMOption("FoldStableValues"); | |
630 } catch (IllegalArgumentException e) { | |
631 tmp = null; | |
632 } | |
633 isStableEnabled = (tmp == null ? false : Boolean.parseBoolean(tmp.getValue())); | |
634 } | |
635 } | 662 } |