61 }
62
63 public static void main(String[] args) throws Throwable {
64 TestNullableArrays test = new TestNullableArrays();
65 test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
66 }
67
68 // Helper methods
69
70 protected long hash() {
71 return hash(rI, rL);
72 }
73
74 protected long hash(int x, long y) {
75 return MyValue1.createWithFieldsInline(x, y).hash();
76 }
77
78 private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL);
79
80 // Test nullable value type array creation and initialization
81 @Test(valid = ValueTypeArrayFlattenOn)
82 @Test(valid = ValueTypeArrayFlattenOff, failOn = LOAD)
83 public MyValue1?[] test1(int len) {
84 MyValue1?[] va = new MyValue1?[len];
85 if (len > 0) {
86 va[0] = null;
87 }
88 for (int i = 1; i < len; ++i) {
89 va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
90 }
91 return va;
92 }
93
94 @DontCompile
95 public void test1_verifier(boolean warmup) {
96 int len = Math.abs(rI % 10);
97 MyValue1?[] va = test1(len);
98 if (len > 0) {
99 Asserts.assertEQ(va[0], null);
100 }
101 for (int i = 1; i < len; ++i) {
102 Asserts.assertEQ(va[i].hash(), hash());
1723 for (int i = 0; i < 8; ++i) {
1724 Asserts.assertEQ(va[i], null);
1725 }
1726 }
1727
1728 // Test default initialization of value type arrays: large array
1729 @Test
1730 public MyValue1?[] test65() {
1731 return new MyValue1?[32];
1732 }
1733
1734 @DontCompile
1735 public void test65_verifier(boolean warmup) {
1736 MyValue1?[] va = test65();
1737 for (int i = 0; i < 32; ++i) {
1738 Asserts.assertEQ(va[i], null);
1739 }
1740 }
1741
1742 // Check init store elimination
1743 @Test
1744 public MyValue1?[] test66(MyValue1? vt) {
1745 MyValue1?[] va = new MyValue1?[1];
1746 va[0] = vt;
1747 return va;
1748 }
1749
1750 @DontCompile
1751 public void test66_verifier(boolean warmup) {
1752 MyValue1? vt = MyValue1.createWithFieldsDontInline(rI, rL);
1753 MyValue1?[] va = test66(vt);
1754 Asserts.assertEQ(va[0].hashPrimitive(), vt.hashPrimitive());
1755 }
1756
1757 // Zeroing elimination and arraycopy
1758 @Test
1759 public MyValue1?[] test67(MyValue1?[] src) {
1760 MyValue1?[] dst = new MyValue1?[16];
1761 System.arraycopy(src, 0, dst, 0, 13);
1762 return dst;
1763 }
2226 Asserts.assertEquals(res, testValue1.hash());
2227 res = test82(va, va, testValue1, null, 3, true);
2228 Asserts.assertEquals(va[0].hash(), testValue1.hash());
2229 Asserts.assertEquals(res, testValue1.hash());
2230 }
2231
2232 @Test(failOn = ALLOC + ALLOCA + STORE)
2233 public static long test83(MyValue1[] va) {
2234 MyValue1?[] result = va;
2235 return result[0].hash();
2236 }
2237
2238 @DontCompile
2239 public void test83_verifier(boolean warmup) {
2240 MyValue1[] va = new MyValue1[42];
2241 va[0] = testValue1;
2242 long res = test83(va);
2243 Asserts.assertEquals(res, testValue1.hash());
2244 }
2245
2246 @Test(valid = ValueTypeArrayFlattenOn, failOn = ALLOC + ALLOCA + LOOP + STORE + TRAP)
2247 @Test(valid = ValueTypeArrayFlattenOff)
2248 public static MyValue1?[] test84(MyValue1 vt1, MyValue1? vt2) {
2249 MyValue1?[] result = new MyValue1[2];
2250 result[0] = vt1;
2251 result[1] = vt2;
2252 return result;
2253 }
2254
2255 @DontCompile
2256 public void test84_verifier(boolean warmup) {
2257 MyValue1?[] res = test84(testValue1, testValue1);
2258 Asserts.assertEquals(res[0].hash(), testValue1.hash());
2259 Asserts.assertEquals(res[1].hash(), testValue1.hash());
2260 try {
2261 test84(testValue1, null);
2262 throw new RuntimeException("NullPointerException expected");
2263 } catch (NullPointerException npe) {
2264 // Expected
2265 }
2266 }
|
61 }
62
63 public static void main(String[] args) throws Throwable {
64 TestNullableArrays test = new TestNullableArrays();
65 test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
66 }
67
68 // Helper methods
69
70 protected long hash() {
71 return hash(rI, rL);
72 }
73
74 protected long hash(int x, long y) {
75 return MyValue1.createWithFieldsInline(x, y).hash();
76 }
77
78 private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL);
79
80 // Test nullable value type array creation and initialization
81 @Test(valid = ValueTypeArrayFlattenOn, match = { ALLOCA }, matchCount = { 1 })
82 @Test(valid = ValueTypeArrayFlattenOff, match = { ALLOCA }, matchCount = { 1 }, failOn = LOAD)
83 public MyValue1?[] test1(int len) {
84 MyValue1?[] va = new MyValue1?[len];
85 if (len > 0) {
86 va[0] = null;
87 }
88 for (int i = 1; i < len; ++i) {
89 va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
90 }
91 return va;
92 }
93
94 @DontCompile
95 public void test1_verifier(boolean warmup) {
96 int len = Math.abs(rI % 10);
97 MyValue1?[] va = test1(len);
98 if (len > 0) {
99 Asserts.assertEQ(va[0], null);
100 }
101 for (int i = 1; i < len; ++i) {
102 Asserts.assertEQ(va[i].hash(), hash());
1723 for (int i = 0; i < 8; ++i) {
1724 Asserts.assertEQ(va[i], null);
1725 }
1726 }
1727
1728 // Test default initialization of value type arrays: large array
1729 @Test
1730 public MyValue1?[] test65() {
1731 return new MyValue1?[32];
1732 }
1733
1734 @DontCompile
1735 public void test65_verifier(boolean warmup) {
1736 MyValue1?[] va = test65();
1737 for (int i = 0; i < 32; ++i) {
1738 Asserts.assertEQ(va[i], null);
1739 }
1740 }
1741
1742 // Check init store elimination
1743 @Test(match = { ALLOCA }, matchCount = { 1 })
1744 public MyValue1?[] test66(MyValue1? vt) {
1745 MyValue1?[] va = new MyValue1?[1];
1746 va[0] = vt;
1747 return va;
1748 }
1749
1750 @DontCompile
1751 public void test66_verifier(boolean warmup) {
1752 MyValue1? vt = MyValue1.createWithFieldsDontInline(rI, rL);
1753 MyValue1?[] va = test66(vt);
1754 Asserts.assertEQ(va[0].hashPrimitive(), vt.hashPrimitive());
1755 }
1756
1757 // Zeroing elimination and arraycopy
1758 @Test
1759 public MyValue1?[] test67(MyValue1?[] src) {
1760 MyValue1?[] dst = new MyValue1?[16];
1761 System.arraycopy(src, 0, dst, 0, 13);
1762 return dst;
1763 }
2226 Asserts.assertEquals(res, testValue1.hash());
2227 res = test82(va, va, testValue1, null, 3, true);
2228 Asserts.assertEquals(va[0].hash(), testValue1.hash());
2229 Asserts.assertEquals(res, testValue1.hash());
2230 }
2231
2232 @Test(failOn = ALLOC + ALLOCA + STORE)
2233 public static long test83(MyValue1[] va) {
2234 MyValue1?[] result = va;
2235 return result[0].hash();
2236 }
2237
2238 @DontCompile
2239 public void test83_verifier(boolean warmup) {
2240 MyValue1[] va = new MyValue1[42];
2241 va[0] = testValue1;
2242 long res = test83(va);
2243 Asserts.assertEquals(res, testValue1.hash());
2244 }
2245
2246 @Test(valid = ValueTypeArrayFlattenOn, failOn = ALLOC + LOOP + STORE + TRAP)
2247 @Test(valid = ValueTypeArrayFlattenOff)
2248 public static MyValue1?[] test84(MyValue1 vt1, MyValue1? vt2) {
2249 MyValue1?[] result = new MyValue1[2];
2250 result[0] = vt1;
2251 result[1] = vt2;
2252 return result;
2253 }
2254
2255 @DontCompile
2256 public void test84_verifier(boolean warmup) {
2257 MyValue1?[] res = test84(testValue1, testValue1);
2258 Asserts.assertEquals(res[0].hash(), testValue1.hash());
2259 Asserts.assertEquals(res[1].hash(), testValue1.hash());
2260 try {
2261 test84(testValue1, null);
2262 throw new RuntimeException("NullPointerException expected");
2263 } catch (NullPointerException npe) {
2264 // Expected
2265 }
2266 }
|