-
Notifications
You must be signed in to change notification settings - Fork 99
/
TestLWorld.java
3783 lines (3298 loc) · 119 KB
/
TestLWorld.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package compiler.valhalla.inlinetypes;
import java.lang.invoke.*;
import java.lang.reflect.Method;
import java.util.Arrays;
import jdk.test.lib.Asserts;
import test.java.lang.invoke.lib.InstructionHelper;
/*
* @test
* @key randomness
* @summary Test inline types in LWorld.
* @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /testlibrary /compiler/whitebox /
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
* @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64")
* @compile TestLWorld.java
* @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
* @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI
* compiler.valhalla.inlinetypes.InlineTypeTest
* compiler.valhalla.inlinetypes.TestLWorld
*/
public class TestLWorld extends InlineTypeTest {
// Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters()
@Override
public String[] getExtraVMParameters(int scenario) {
switch (scenario) {
case 2: return new String[] {"-DVerifyIR=false"};
case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"};
case 4: return new String[] {"-XX:-MonomorphicArrayCheck"};
}
return null;
}
public static void main(String[] args) throws Throwable {
// Make sure Test140Value is loaded but not linked
Class<?> class1 = Test140Value.class;
// Make sure Test141Value is linked but not initialized
Class<?> class2 = Test141Value.class;
class2.getDeclaredFields();
TestLWorld test = new TestLWorld();
test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class,
MyValue3Inline.class, Test51Value.class);
}
// Helper methods
private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL);
private static final MyValue2 testValue2 = MyValue2.createWithFieldsInline(rI, rD);
protected long hash() {
return testValue1.hash();
}
// Test passing an inline type as an Object
@DontInline
public Object test1_dontinline1(Object o) {
return o;
}
@DontInline
public MyValue1 test1_dontinline2(Object o) {
return (MyValue1)o;
}
@ForceInline
public Object test1_inline1(Object o) {
return o;
}
@ForceInline
public MyValue1 test1_inline2(Object o) {
return (MyValue1)o;
}
@Test()
public MyValue1 test1() {
MyValue1 vt = testValue1;
vt = (MyValue1)test1_dontinline1(vt);
vt = test1_dontinline2(vt);
vt = (MyValue1)test1_inline1(vt);
vt = test1_inline2(vt);
return vt;
}
@DontCompile
public void test1_verifier(boolean warmup) {
Asserts.assertEQ(test1().hash(), hash());
}
// Test storing/loading inline types to/from Object and inline type fields
Object objectField1 = null;
Object objectField2 = null;
Object objectField3 = null;
Object objectField4 = null;
Object objectField5 = null;
Object objectField6 = null;
MyValue1 valueField1 = testValue1;
MyValue1 valueField2 = testValue1;
MyValue1.ref valueField3 = testValue1;
MyValue1 valueField4;
MyValue1.ref valueField5;
static MyValue1.ref staticValueField1 = testValue1;
static MyValue1 staticValueField2 = testValue1;
static MyValue1 staticValueField3;
static MyValue1.ref staticValueField4;
@DontInline
public Object readValueField5() {
return (Object)valueField5;
}
@DontInline
public Object readStaticValueField4() {
return (Object)staticValueField4;
}
@Test()
public long test2(MyValue1 vt1, Object vt2) {
objectField1 = vt1;
objectField2 = (MyValue1)vt2;
objectField3 = testValue1;
objectField4 = MyValue1.createWithFieldsDontInline(rI, rL);
objectField5 = valueField1;
objectField6 = valueField3;
valueField1 = (MyValue1)objectField1;
valueField2 = (MyValue1)vt2;
valueField3 = (MyValue1)vt2;
staticValueField1 = (MyValue1)objectField1;
staticValueField2 = (MyValue1)vt1;
// Don't inline these methods because reading NULL will trigger a deoptimization
if (readValueField5() != null || readStaticValueField4() != null) {
throw new RuntimeException("Should be null");
}
return ((MyValue1)objectField1).hash() + ((MyValue1)objectField2).hash() +
((MyValue1)objectField3).hash() + ((MyValue1)objectField4).hash() +
((MyValue1)objectField5).hash() + ((MyValue1)objectField6).hash() +
valueField1.hash() + valueField2.hash() + valueField3.hash() + valueField4.hashPrimitive() +
staticValueField1.hash() + staticValueField2.hash() + staticValueField3.hashPrimitive();
}
@DontCompile
public void test2_verifier(boolean warmup) {
MyValue1 vt = testValue1;
MyValue1 def = MyValue1.createDefaultDontInline();
long result = test2(vt, vt);
Asserts.assertEQ(result, 11*vt.hash() + 2*def.hashPrimitive());
}
// Test merging inline types and objects
@Test()
public Object test3(int state) {
Object res = null;
if (state == 0) {
res = Integer.valueOf(rI);
} else if (state == 1) {
res = MyValue1.createWithFieldsInline(rI, rL);
} else if (state == 2) {
res = MyValue1.createWithFieldsDontInline(rI, rL);
} else if (state == 3) {
res = (MyValue1)objectField1;
} else if (state == 4) {
res = valueField1;
} else if (state == 5) {
res = null;
} else if (state == 6) {
res = MyValue2.createWithFieldsInline(rI, rD);
} else if (state == 7) {
res = testValue2;
}
return res;
}
@DontCompile
public void test3_verifier(boolean warmup) {
objectField1 = valueField1;
Object result = null;
result = test3(0);
Asserts.assertEQ((Integer)result, rI);
result = test3(1);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test3(2);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test3(3);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test3(4);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test3(5);
Asserts.assertEQ(result, null);
result = test3(6);
Asserts.assertEQ(((MyValue2)result).hash(), testValue2.hash());
result = test3(7);
Asserts.assertEQ(((MyValue2)result).hash(), testValue2.hash());
}
// Test merging inline types and objects in loops
@Test()
public Object test4(int iters) {
Object res = Integer.valueOf(rI);
for (int i = 0; i < iters; ++i) {
if (res instanceof Integer) {
res = MyValue1.createWithFieldsInline(rI, rL);
} else {
res = MyValue1.createWithFieldsInline(((MyValue1)res).x + 1, rL);
}
}
return res;
}
@DontCompile
public void test4_verifier(boolean warmup) {
Integer result1 = (Integer)test4(0);
Asserts.assertEQ(result1, rI);
int iters = (Math.abs(rI) % 10) + 1;
MyValue1 result2 = (MyValue1)test4(iters);
MyValue1 vt = MyValue1.createWithFieldsInline(rI + iters - 1, rL);
Asserts.assertEQ(result2.hash(), vt.hash());
}
// Test inline types in object variables that are live at safepoint
@Test(failOn = ALLOC + STORE + LOOP)
public long test5(MyValue1 arg, boolean deopt) {
Object vt1 = MyValue1.createWithFieldsInline(rI, rL);
Object vt2 = MyValue1.createWithFieldsDontInline(rI, rL);
Object vt3 = arg;
Object vt4 = valueField1;
if (deopt) {
// uncommon trap
WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test5"));
}
return ((MyValue1)vt1).hash() + ((MyValue1)vt2).hash() +
((MyValue1)vt3).hash() + ((MyValue1)vt4).hash();
}
@DontCompile
public void test5_verifier(boolean warmup) {
long result = test5(valueField1, !warmup);
Asserts.assertEQ(result, 4*hash());
}
// Test comparing inline types with objects
@Test(failOn = LOAD + LOOP)
public boolean test6(Object arg) {
Object vt = MyValue1.createWithFieldsInline(rI, rL);
if (vt == arg || vt == (Object)valueField1 || vt == objectField1 || vt == null ||
arg == vt || (Object)valueField1 == vt || objectField1 == vt || null == vt) {
return true;
}
return false;
}
@DontCompile
public void test6_verifier(boolean warmup) {
boolean result = test6(null);
Asserts.assertFalse(result);
}
// merge of inline type and non-inline type
@Test
public Object test7(boolean flag) {
Object res = null;
if (flag) {
res = valueField1;
} else {
res = objectField1;
}
return res;
}
@DontCompile
public void test7_verifier(boolean warmup) {
test7(true);
test7(false);
}
@Test
public Object test8(boolean flag) {
Object res = null;
if (flag) {
res = objectField1;
} else {
res = valueField1;
}
return res;
}
@DontCompile
public void test8_verifier(boolean warmup) {
test8(true);
test8(false);
}
// merge of inline types in a loop, stored in an object local
@Test
public Object test9() {
Object o = valueField1;
for (int i = 1; i < 100; i *= 2) {
MyValue1 v = (MyValue1)o;
o = MyValue1.setX(v, v.x + 1);
}
return o;
}
@DontCompile
public void test9_verifier(boolean warmup) {
test9();
}
// merge of inline types in an object local
@ForceInline
public Object test10_helper() {
return valueField1;
}
@Test(failOn = ALLOC + LOAD + STORE)
public void test10(boolean flag) {
Object o = null;
if (flag) {
o = valueField1;
} else {
o = test10_helper();
}
valueField1 = (MyValue1)o;
}
@DontCompile
public void test10_verifier(boolean warmup) {
test10(true);
test10(false);
}
// Interface tests
@DontInline
public MyInterface test11_dontinline1(MyInterface o) {
return o;
}
@DontInline
public MyValue1 test11_dontinline2(MyInterface o) {
return (MyValue1)o;
}
@ForceInline
public MyInterface test11_inline1(MyInterface o) {
return o;
}
@ForceInline
public MyValue1 test11_inline2(MyInterface o) {
return (MyValue1)o;
}
@Test()
public MyValue1 test11() {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
vt = (MyValue1)test11_dontinline1(vt);
vt = test11_dontinline2(vt);
vt = (MyValue1)test11_inline1(vt);
vt = test11_inline2(vt);
return vt;
}
@DontCompile
public void test11_verifier(boolean warmup) {
Asserts.assertEQ(test11().hash(), hash());
}
// Test storing/loading inline types to/from interface and inline type fields
MyInterface interfaceField1 = null;
MyInterface interfaceField2 = null;
MyInterface interfaceField3 = null;
MyInterface interfaceField4 = null;
MyInterface interfaceField5 = null;
MyInterface interfaceField6 = null;
@DontInline
public MyInterface readValueField5AsInterface() {
return (MyInterface)valueField5;
}
@DontInline
public MyInterface readStaticValueField4AsInterface() {
return (MyInterface)staticValueField4;
}
@Test()
public long test12(MyValue1 vt1, MyInterface vt2) {
interfaceField1 = vt1;
interfaceField2 = (MyValue1)vt2;
interfaceField3 = MyValue1.createWithFieldsInline(rI, rL);
interfaceField4 = MyValue1.createWithFieldsDontInline(rI, rL);
interfaceField5 = valueField1;
interfaceField6 = valueField3;
valueField1 = (MyValue1)interfaceField1;
valueField2 = (MyValue1)vt2;
valueField3 = (MyValue1)vt2;
staticValueField1 = (MyValue1)interfaceField1;
staticValueField2 = (MyValue1)vt1;
// Don't inline these methods because reading NULL will trigger a deoptimization
if (readValueField5AsInterface() != null || readStaticValueField4AsInterface() != null) {
throw new RuntimeException("Should be null");
}
return ((MyValue1)interfaceField1).hash() + ((MyValue1)interfaceField2).hash() +
((MyValue1)interfaceField3).hash() + ((MyValue1)interfaceField4).hash() +
((MyValue1)interfaceField5).hash() + ((MyValue1)interfaceField6).hash() +
valueField1.hash() + valueField2.hash() + valueField3.hash() + valueField4.hashPrimitive() +
staticValueField1.hash() + staticValueField2.hash() + staticValueField3.hashPrimitive();
}
@DontCompile
public void test12_verifier(boolean warmup) {
MyValue1 vt = testValue1;
MyValue1 def = MyValue1.createDefaultDontInline();
long result = test12(vt, vt);
Asserts.assertEQ(result, 11*vt.hash() + 2*def.hashPrimitive());
}
class MyObject1 implements MyInterface {
public int x;
public MyObject1(int x) {
this.x = x;
}
@ForceInline
public long hash() {
return x;
}
}
// Test merging inline types and interfaces
@Test()
public MyInterface test13(int state) {
MyInterface res = null;
if (state == 0) {
res = new MyObject1(rI);
} else if (state == 1) {
res = MyValue1.createWithFieldsInline(rI, rL);
} else if (state == 2) {
res = MyValue1.createWithFieldsDontInline(rI, rL);
} else if (state == 3) {
res = (MyValue1)objectField1;
} else if (state == 4) {
res = valueField1;
} else if (state == 5) {
res = null;
}
return res;
}
@DontCompile
public void test13_verifier(boolean warmup) {
objectField1 = valueField1;
MyInterface result = null;
result = test13(0);
Asserts.assertEQ(((MyObject1)result).x, rI);
result = test13(1);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test13(2);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test13(3);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test13(4);
Asserts.assertEQ(((MyValue1)result).hash(), hash());
result = test13(5);
Asserts.assertEQ(result, null);
}
// Test merging inline types and interfaces in loops
@Test()
public MyInterface test14(int iters) {
MyInterface res = new MyObject1(rI);
for (int i = 0; i < iters; ++i) {
if (res instanceof MyObject1) {
res = MyValue1.createWithFieldsInline(rI, rL);
} else {
res = MyValue1.createWithFieldsInline(((MyValue1)res).x + 1, rL);
}
}
return res;
}
@DontCompile
public void test14_verifier(boolean warmup) {
MyObject1 result1 = (MyObject1)test14(0);
Asserts.assertEQ(result1.x, rI);
int iters = (Math.abs(rI) % 10) + 1;
MyValue1 result2 = (MyValue1)test14(iters);
MyValue1 vt = MyValue1.createWithFieldsInline(rI + iters - 1, rL);
Asserts.assertEQ(result2.hash(), vt.hash());
}
// Test inline types in interface variables that are live at safepoint
@Test(failOn = ALLOC + STORE + LOOP)
public long test15(MyValue1 arg, boolean deopt) {
MyInterface vt1 = MyValue1.createWithFieldsInline(rI, rL);
MyInterface vt2 = MyValue1.createWithFieldsDontInline(rI, rL);
MyInterface vt3 = arg;
MyInterface vt4 = valueField1;
if (deopt) {
// uncommon trap
WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test15"));
}
return ((MyValue1)vt1).hash() + ((MyValue1)vt2).hash() +
((MyValue1)vt3).hash() + ((MyValue1)vt4).hash();
}
@DontCompile
public void test15_verifier(boolean warmup) {
long result = test15(valueField1, !warmup);
Asserts.assertEQ(result, 4*hash());
}
// Test comparing inline types with interfaces
@Test(failOn = LOAD + LOOP)
public boolean test16(Object arg) {
MyInterface vt = MyValue1.createWithFieldsInline(rI, rL);
if (vt == arg || vt == (MyInterface)valueField1 || vt == interfaceField1 || vt == null ||
arg == vt || (MyInterface)valueField1 == vt || interfaceField1 == vt || null == vt) {
return true;
}
return false;
}
@DontCompile
public void test16_verifier(boolean warmup) {
boolean result = test16(null);
Asserts.assertFalse(result);
}
// Test subtype check when casting to inline type
@Test
public MyValue1 test17(MyValue1 vt, Object obj) {
try {
vt = (MyValue1)obj;
throw new RuntimeException("ClassCastException expected");
} catch (ClassCastException e) {
// Expected
}
return vt;
}
@DontCompile
public void test17_verifier(boolean warmup) {
MyValue1 vt = testValue1;
MyValue1 result = test17(vt, Integer.valueOf(rI));
Asserts.assertEquals(result.hash(), vt.hash());
}
@Test
public MyValue1 test18(MyValue1 vt) {
Object obj = vt;
vt = (MyValue1)obj;
return vt;
}
@DontCompile
public void test18_verifier(boolean warmup) {
MyValue1 vt = testValue1;
MyValue1 result = test18(vt);
Asserts.assertEquals(result.hash(), vt.hash());
}
@Test
public void test19(MyValue1 vt) {
Object obj = vt;
try {
MyValue2 vt2 = (MyValue2)obj;
throw new RuntimeException("ClassCastException expected");
} catch (ClassCastException e) {
// Expected
}
}
@DontCompile
public void test19_verifier(boolean warmup) {
test19(valueField1);
}
@Test
public void test20(MyValue1 vt) {
Object obj = vt;
try {
Integer i = (Integer)obj;
throw new RuntimeException("ClassCastException expected");
} catch (ClassCastException e) {
// Expected
}
}
@DontCompile
public void test20_verifier(boolean warmup) {
test20(valueField1);
}
// Array tests
private static final MyValue1[] testValue1Array = new MyValue1[] {testValue1,
testValue1,
testValue1};
private static final MyValue1[][] testValue1Array2 = new MyValue1[][] {testValue1Array,
testValue1Array,
testValue1Array};
private static final MyValue2[] testValue2Array = new MyValue2[] {testValue2,
testValue2,
testValue2};
private static final Integer[] testIntegerArray = new Integer[42];
// Test load from (flattened) inline type array disguised as object array
@Test()
public Object test21(Object[] oa, int index) {
return oa[index];
}
@DontCompile
public void test21_verifier(boolean warmup) {
MyValue1 result = (MyValue1)test21(testValue1Array, Math.abs(rI) % 3);
Asserts.assertEQ(result.hash(), hash());
}
// Test load from (flattened) inline type array disguised as interface array
@Test()
public Object test22Interface(MyInterface[] ia, int index) {
return ia[index];
}
@DontCompile
public void test22Interface_verifier(boolean warmup) {
MyValue1 result = (MyValue1)test22Interface(testValue1Array, Math.abs(rI) % 3);
Asserts.assertEQ(result.hash(), hash());
}
// Test load from (flattened) inline type array disguised as abstract array
@Test()
public Object test22Abstract(MyAbstract[] ia, int index) {
return ia[index];
}
@DontCompile
public void test22Abstract_verifier(boolean warmup) {
MyValue1 result = (MyValue1)test22Abstract(testValue1Array, Math.abs(rI) % 3);
Asserts.assertEQ(result.hash(), hash());
}
// Test inline store to (flattened) inline type array disguised as object array
@ForceInline
public void test23_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test23(Object[] oa, MyValue1 vt, int index) {
test23_inline(oa, vt, index);
}
@DontCompile
public void test23_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test23(testValue1Array, vt, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt.hash());
testValue1Array[index] = testValue1;
try {
test23(testValue2Array, vt, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue2Array[index].hash(), testValue2.hash());
}
@ForceInline
public void test24_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test24(Object[] oa, MyValue1 vt, int index) {
test24_inline(oa, vt, index);
}
@DontCompile
public void test24_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test24(testIntegerArray, testValue1, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
}
@ForceInline
public void test25_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test25(Object[] oa, MyValue1 vt, int index) {
test25_inline(oa, vt, index);
}
@DontCompile
public void test25_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test25(null, testValue1, index);
throw new RuntimeException("No NPE thrown");
} catch (NullPointerException e) {
// Expected
}
}
// Test inline store to (flattened) inline type array disguised as interface array
@ForceInline
public void test26Interface_inline(MyInterface[] ia, MyInterface i, int index) {
ia[index] = i;
}
@Test()
public void test26Interface(MyInterface[] ia, MyValue1 vt, int index) {
test26Interface_inline(ia, vt, index);
}
@DontCompile
public void test26Interface_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test26Interface(testValue1Array, vt, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt.hash());
testValue1Array[index] = testValue1;
try {
test26Interface(testValue2Array, vt, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue2Array[index].hash(), testValue2.hash());
}
@ForceInline
public void test27Interface_inline(MyInterface[] ia, MyInterface i, int index) {
ia[index] = i;
}
@Test()
public void test27Interface(MyInterface[] ia, MyValue1 vt, int index) {
test27Interface_inline(ia, vt, index);
}
@DontCompile
public void test27Interface_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test27Interface(null, testValue1, index);
throw new RuntimeException("No NPE thrown");
} catch (NullPointerException e) {
// Expected
}
}
// Test inline store to (flattened) inline type array disguised as abstract array
@ForceInline
public void test26Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) {
ia[index] = i;
}
@Test()
public void test26Abstract(MyAbstract[] ia, MyValue1 vt, int index) {
test26Abstract_inline(ia, vt, index);
}
@DontCompile
public void test26Abstract_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test26Abstract(testValue1Array, vt, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt.hash());
testValue1Array[index] = testValue1;
try {
test26Abstract(testValue2Array, vt, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue2Array[index].hash(), testValue2.hash());
}
@ForceInline
public void test27Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) {
ia[index] = i;
}
@Test()
public void test27Abstract(MyAbstract[] ia, MyValue1 vt, int index) {
test27Abstract_inline(ia, vt, index);
}
@DontCompile
public void test27Abstract_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test27Abstract(null, testValue1, index);
throw new RuntimeException("No NPE thrown");
} catch (NullPointerException e) {
// Expected
}
}
// Test object store to (flattened) inline type array disguised as object array
@ForceInline
public void test28_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test28(Object[] oa, Object o, int index) {
test28_inline(oa, o, index);
}
@DontCompile
public void test28_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test28(testValue1Array, vt1, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
try {
test28(testValue1Array, testValue2, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
testValue1Array[index] = testValue1;
}
@ForceInline
public void test29_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test29(Object[] oa, Object o, int index) {
test29_inline(oa, o, index);
}
@DontCompile
public void test29_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test29(testValue2Array, testValue1, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue2Array[index].hash(), testValue2.hash());
}
@ForceInline
public void test30_inline(Object[] oa, Object o, int index) {
oa[index] = o;
}
@Test()
public void test30(Object[] oa, Object o, int index) {
test30_inline(oa, o, index);
}
@DontCompile
public void test30_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test30(testIntegerArray, testValue1, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
}
// Test inline store to (flattened) inline type array disguised as interface array
@ForceInline
public void test31Interface_inline(MyInterface[] ia, MyInterface i, int index) {
ia[index] = i;
}
@Test()
public void test31Interface(MyInterface[] ia, MyInterface i, int index) {
test31Interface_inline(ia, i, index);
}
@DontCompile
public void test31Interface_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test31Interface(testValue1Array, vt1, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
try {
test31Interface(testValue1Array, testValue2, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
testValue1Array[index] = testValue1;
}
@ForceInline
public void test32Interface_inline(MyInterface[] ia, MyInterface i, int index) {
ia[index] = i;
}
@Test()
public void test32Interface(MyInterface[] ia, MyInterface i, int index) {
test32Interface_inline(ia, i, index);
}
@DontCompile
public void test32Interface_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test32Interface(testValue2Array, testValue1, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
}
// Test inline store to (flattened) inline type array disguised as abstract array
@ForceInline
public void test31Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) {
ia[index] = i;
}
@Test()
public void test31Abstract(MyAbstract[] ia, MyAbstract i, int index) {
test31Abstract_inline(ia, i, index);
}
@DontCompile
public void test31Abstract_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
test31Abstract(testValue1Array, vt1, index);
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
try {
test31Abstract(testValue1Array, testValue2, index);
throw new RuntimeException("No ArrayStoreException thrown");
} catch (ArrayStoreException e) {
// Expected
}
Asserts.assertEQ(testValue1Array[index].hash(), vt1.hash());
testValue1Array[index] = testValue1;
}
@ForceInline
public void test32Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) {
ia[index] = i;
}
@Test()
public void test32Abstract(MyAbstract[] ia, MyAbstract i, int index) {
test32Abstract_inline(ia, i, index);
}
@DontCompile
public void test32Abstract_verifier(boolean warmup) {
int index = Math.abs(rI) % 3;
try {
test32Abstract(testValue2Array, testValue1, index);