< prev index next >
test/hotspot/jtreg/compiler/valhalla/valuetypes/TestIntrinsics.java
Print this page
rev 55127 : 8223351: [lworld] Primary mirror and nullable mirror for inline type
Reviewed-by: tbd
@@ -65,34 +65,34 @@
return supercls.isAssignableFrom(subcls);
}
public void test1_verifier(boolean warmup) {
Asserts.assertTrue(test1(java.util.AbstractList.class, java.util.ArrayList.class), "test1_1 failed");
- Asserts.assertTrue(test1(MyValue1.class.asBoxType(), MyValue1.class.asBoxType()), "test1_2 failed");
- Asserts.assertTrue(test1(MyValue1.class.asValueType(), MyValue1.class.asValueType()), "test1_3 failed");
- Asserts.assertTrue(test1(MyValue1.class.asBoxType(), MyValue1.class.asValueType()), "test1_4 failed");
- Asserts.assertTrue(test1(MyValue1.class.asValueType(), MyValue1.class.asBoxType()), "test1_5 failed");
+ Asserts.assertTrue(test1(MyValue1.class.asNullableType(), MyValue1.class.asNullableType()), "test1_2 failed");
+ Asserts.assertTrue(test1(MyValue1.class.asPrimaryType(), MyValue1.class.asPrimaryType()), "test1_3 failed");
+ Asserts.assertTrue(test1(MyValue1.class.asNullableType(), MyValue1.class.asPrimaryType()), "test1_4 failed");
+ Asserts.assertTrue(test1(MyValue1.class.asPrimaryType(), MyValue1.class.asNullableType()), "test1_5 failed");
Asserts.assertTrue(test1(Object.class, java.util.ArrayList.class), "test1_6 failed");
- Asserts.assertTrue(test1(Object.class, MyValue1.class.asBoxType()), "test1_7 failed");
- Asserts.assertTrue(test1(Object.class, MyValue1.class.asValueType()), "test1_8 failed");
- Asserts.assertTrue(!test1(MyValue1.class.asBoxType(), Object.class), "test1_9 failed");
- Asserts.assertTrue(!test1(MyValue1.class.asValueType(), Object.class), "test1_10 failed");
+ Asserts.assertTrue(test1(Object.class, MyValue1.class.asNullableType()), "test1_7 failed");
+ Asserts.assertTrue(test1(Object.class, MyValue1.class.asPrimaryType()), "test1_8 failed");
+ Asserts.assertTrue(!test1(MyValue1.class.asNullableType(), Object.class), "test1_9 failed");
+ Asserts.assertTrue(!test1(MyValue1.class.asPrimaryType(), Object.class), "test1_10 failed");
}
// Verify that Class::isAssignableFrom checks with statically known classes are folded
@Test(failOn = LOADK)
public boolean test2() {
boolean check1 = java.util.AbstractList.class.isAssignableFrom(java.util.ArrayList.class);
- boolean check2 = MyValue1.class.asBoxType().isAssignableFrom(MyValue1.class.asBoxType());
- boolean check3 = MyValue1.class.asValueType().isAssignableFrom(MyValue1.class.asValueType());
- boolean check4 = MyValue1.class.asBoxType().isAssignableFrom(MyValue1.class.asValueType());
- boolean check5 = MyValue1.class.asValueType().isAssignableFrom(MyValue1.class.asBoxType());
+ boolean check2 = MyValue1.class.asNullableType().isAssignableFrom(MyValue1.class.asNullableType());
+ boolean check3 = MyValue1.class.asPrimaryType().isAssignableFrom(MyValue1.class.asPrimaryType());
+ boolean check4 = MyValue1.class.asNullableType().isAssignableFrom(MyValue1.class.asPrimaryType());
+ boolean check5 = MyValue1.class.asPrimaryType().isAssignableFrom(MyValue1.class.asNullableType());
boolean check6 = Object.class.isAssignableFrom(java.util.ArrayList.class);
- boolean check7 = Object.class.isAssignableFrom(MyValue1.class.asBoxType());
- boolean check8 = Object.class.isAssignableFrom(MyValue1.class.asValueType());
- boolean check9 = !MyValue1.class.asBoxType().isAssignableFrom(Object.class);
- boolean check10 = !MyValue1.class.asValueType().isAssignableFrom(Object.class);
+ boolean check7 = Object.class.isAssignableFrom(MyValue1.class.asNullableType());
+ boolean check8 = Object.class.isAssignableFrom(MyValue1.class.asPrimaryType());
+ boolean check9 = !MyValue1.class.asNullableType().isAssignableFrom(Object.class);
+ boolean check10 = !MyValue1.class.asPrimaryType().isAssignableFrom(Object.class);
return check1 && check2 && check3 && check4 && check5 && check6 && check7 && check8 && check9 && check10;
}
public void test2_verifier(boolean warmup) {
Asserts.assertTrue(test2(), "test2 failed");
@@ -104,21 +104,21 @@
return cls.getSuperclass();
}
public void test3_verifier(boolean warmup) {
Asserts.assertTrue(test3(Object.class) == null, "test3_1 failed");
- Asserts.assertTrue(test3(MyValue1.class.asBoxType()) == Object.class, "test3_2 failed");
- Asserts.assertTrue(test3(MyValue1.class.asValueType()) == Object.class, "test3_3 failed");
+ Asserts.assertTrue(test3(MyValue1.class.asNullableType()) == Object.class, "test3_2 failed");
+ Asserts.assertTrue(test3(MyValue1.class.asPrimaryType()) == Object.class, "test3_3 failed");
Asserts.assertTrue(test3(Class.class) == Object.class, "test3_4 failed");
}
// Verify that Class::getSuperclass checks with statically known classes are folded
@Test(failOn = LOADK)
public boolean test4() {
boolean check1 = Object.class.getSuperclass() == null;
- boolean check2 = MyValue1.class.asBoxType().getSuperclass() == Object.class;
- boolean check3 = MyValue1.class.asValueType().getSuperclass() == Object.class;
+ boolean check2 = MyValue1.class.asNullableType().getSuperclass() == Object.class;
+ boolean check3 = MyValue1.class.asPrimaryType().getSuperclass() == Object.class;
boolean check4 = Class.class.getSuperclass() == Object.class;
return check1 && check2 && check3 && check4;
}
public void test4_verifier(boolean warmup) {
@@ -159,11 +159,11 @@
@DontCompile
public void test7_verifier(boolean warmup) {
int len = Math.abs(rI) % 42;
long hash = MyValue1.createDefaultDontInline().hashPrimitive();
- Object[] va = test7(MyValue1.class.asValueType(), len);
+ Object[] va = test7(MyValue1.class.asPrimaryType(), len);
for (int i = 0; i < len; ++i) {
Asserts.assertEQ(((MyValue1)va[i]).hashPrimitive(), hash);
}
}
@@ -174,13 +174,13 @@
}
@DontCompile
public void test8_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
- boolean result = test8(MyValue1.class.asValueType(), vt);
+ boolean result = test8(MyValue1.class.asPrimaryType(), vt);
Asserts.assertTrue(result);
- result = test8(MyValue1.class.asBoxType(), vt);
+ result = test8(MyValue1.class.asNullableType(), vt);
Asserts.assertTrue(result);
}
@Test()
public boolean test9(Class c, MyValue1 vt) {
@@ -188,13 +188,13 @@
}
@DontCompile
public void test9_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
- boolean result = test9(MyValue2.class.asValueType(), vt);
+ boolean result = test9(MyValue2.class.asPrimaryType(), vt);
Asserts.assertFalse(result);
- result = test9(MyValue2.class.asBoxType(), vt);
+ result = test9(MyValue2.class.asNullableType(), vt);
Asserts.assertFalse(result);
}
// Class.cast
@Test()
@@ -203,11 +203,11 @@
}
@DontCompile
public void test10_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
- Object result = test10(MyValue1.class.asValueType(), vt);
+ Object result = test10(MyValue1.class.asPrimaryType(), vt);
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
}
@Test()
public Object test11(Class c, MyValue1 vt) {
@@ -216,19 +216,19 @@
@DontCompile
public void test11_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
try {
- test11(MyValue2.class.asValueType(), vt);
+ test11(MyValue2.class.asPrimaryType(), vt);
throw new RuntimeException("should have thrown");
} catch (ClassCastException cce) {
}
}
@Test()
public Object test12(MyValue1 vt) {
- return MyValue1.class.asValueType().cast(vt);
+ return MyValue1.class.asPrimaryType().cast(vt);
}
@DontCompile
public void test12_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -236,11 +236,11 @@
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
}
@Test()
public Object test13(MyValue1 vt) {
- return MyValue2.class.asValueType().cast(vt);
+ return MyValue2.class.asPrimaryType().cast(vt);
}
@DontCompile
public void test13_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -252,11 +252,11 @@
}
// value type array creation via reflection
@Test()
public void test14(int len, long hash) {
- Object[] va = (Object[])Array.newInstance(MyValue1.class.asValueType().asBoxType().asValueType(), len);
+ Object[] va = (Object[])Array.newInstance(MyValue1.class.asPrimaryType().asNullableType().asPrimaryType(), len);
for (int i = 0; i < len; ++i) {
Asserts.assertEQ(((MyValue1)va[i]).hashPrimitive(), hash);
}
}
@@ -352,15 +352,15 @@
private static final long Y_OFFSET;
private static final long V1_OFFSET;
private static final boolean V1_FLATTENED;
static {
try {
- Field xField = MyValue1.class.asValueType().getDeclaredField("x");
+ Field xField = MyValue1.class.asPrimaryType().getDeclaredField("x");
X_OFFSET = U.objectFieldOffset(xField);
- Field yField = MyValue1.class.asValueType().getDeclaredField("y");
+ Field yField = MyValue1.class.asPrimaryType().getDeclaredField("y");
Y_OFFSET = U.objectFieldOffset(yField);
- Field v1Field = MyValue1.class.asValueType().getDeclaredField("v1");
+ Field v1Field = MyValue1.class.asPrimaryType().getDeclaredField("v1");
V1_OFFSET = U.objectFieldOffset(v1Field);
V1_FLATTENED = U.isFlattened(v1Field);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -447,11 +447,11 @@
@Test
public Object test26() {
Class<?>[] ca = new Class<?>[1];
for (int i = 0; i < 1; ++i) {
// Folds during loop opts
- ca[i] = MyValue1.class.asValueType();
+ ca[i] = MyValue1.class.asPrimaryType();
}
return Array.newInstance(ca[0], 1);
}
@DontCompile
@@ -532,11 +532,11 @@
// getValue to retrieve flattened field from value
@Test(failOn=CALL_Unsafe)
public MyValue2 test30(MyValue1 v) {
if (V1_FLATTENED) {
- return U.getValue(v, V1_OFFSET, MyValue2.class.asValueType().asBoxType().asValueType());
+ return U.getValue(v, V1_OFFSET, MyValue2.class.asPrimaryType().asNullableType().asPrimaryType());
}
return (MyValue2)U.getReference(v, V1_OFFSET);
}
@DontCompile
@@ -561,11 +561,11 @@
// getValue to retrieve flattened field from object
@Test(failOn=CALL_Unsafe)
public MyValue1 test31() {
if (TEST31_VT_FLATTENED) {
- return U.getValue(this, TEST31_VT_OFFSET, MyValue1.class.asValueType().asBoxType().asValueType());
+ return U.getValue(this, TEST31_VT_OFFSET, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType());
}
return (MyValue1)U.getReference(this, TEST31_VT_OFFSET);
}
@DontCompile
@@ -577,11 +577,11 @@
// putValue to set flattened field in object
@Test(failOn=CALL_Unsafe)
public void test32(MyValue1 vt) {
if (TEST31_VT_FLATTENED) {
- U.putValue(this, TEST31_VT_OFFSET, MyValue1.class.asValueType().asBoxType().asValueType(), vt);
+ U.putValue(this, TEST31_VT_OFFSET, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType(), vt);
} else {
U.putReference(this, TEST31_VT_OFFSET, vt);
}
}
@@ -607,11 +607,11 @@
}
// getValue to retrieve flattened field from array
@Test(failOn=CALL_Unsafe)
public MyValue1 test33(MyValue1[] arr) {
if (TEST33_FLATTENED_ARRAY) {
- return U.getValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class.asValueType().asBoxType().asValueType());
+ return U.getValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType());
}
return (MyValue1)U.getReference(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE);
}
@DontCompile
@@ -625,11 +625,11 @@
// putValue to set flattened field in array
@Test(failOn=CALL_Unsafe)
public void test34(MyValue1[] arr, MyValue1 vt) {
if (TEST33_FLATTENED_ARRAY) {
- U.putValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class.asValueType().asBoxType().asValueType(), vt);
+ U.putValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType(), vt);
} else {
U.putReference(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, vt);
}
}
@@ -644,11 +644,11 @@
// getValue to retrieve flattened field from object with unknown
// container type
@Test(failOn=CALL_Unsafe)
public MyValue1 test35(Object o) {
if (TEST31_VT_FLATTENED) {
- return U.getValue(o, TEST31_VT_OFFSET, MyValue1.class.asValueType().asBoxType().asValueType());
+ return U.getValue(o, TEST31_VT_OFFSET, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType());
}
return (MyValue1)U.getReference(o, TEST31_VT_OFFSET);
}
@DontCompile
@@ -661,11 +661,11 @@
// getValue to retrieve flattened field from object at unknown
// offset
@Test(failOn=CALL_Unsafe)
public MyValue1 test36(long offset) {
if (TEST31_VT_FLATTENED) {
- return U.getValue(this, offset, MyValue1.class.asValueType().asBoxType().asValueType());
+ return U.getValue(this, offset, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType());
}
return (MyValue1)U.getReference(this, offset);
}
@DontCompile
@@ -678,11 +678,11 @@
// putValue to set flattened field in object with unknown
// container
@Test(failOn=CALL_Unsafe)
public void test37(Object o, MyValue1 vt) {
if (TEST31_VT_FLATTENED) {
- U.putValue(o, TEST31_VT_OFFSET, MyValue1.class.asValueType().asBoxType().asValueType(), vt);
+ U.putValue(o, TEST31_VT_OFFSET, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType(), vt);
} else {
U.putReference(o, TEST31_VT_OFFSET, vt);
}
}
@@ -697,11 +697,11 @@
// putValue to set flattened field in object, non value argument
// to store
@Test(match = { CALL_Unsafe }, matchCount = { 1 })
public void test38(Object o) {
if (TEST31_VT_FLATTENED) {
- U.putValue(this, TEST31_VT_OFFSET, MyValue1.class.asValueType().asBoxType().asValueType(), o);
+ U.putValue(this, TEST31_VT_OFFSET, MyValue1.class.asPrimaryType().asNullableType().asPrimaryType(), o);
} else {
U.putReference(this, TEST31_VT_OFFSET, o);
}
}
@@ -736,11 +736,11 @@
}
@DontCompile
public void test40_verifier(boolean warmup) {
int len = Math.abs(rI) % 42;
- Object[] va = test40(MyValue1.class.asBoxType(), len);
+ Object[] va = test40(MyValue1.class.asNullableType(), len);
for (int i = 0; i < len; ++i) {
Asserts.assertEQ(va[i], null);
}
}
@@ -751,13 +751,13 @@
}
@DontCompile
public void test41_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
- boolean result = test41(MyValue1.class.asBoxType(), vt);
+ boolean result = test41(MyValue1.class.asNullableType(), vt);
Asserts.assertTrue(result);
- result = test41(MyValue1.class.asValueType(), vt);
+ result = test41(MyValue1.class.asPrimaryType(), vt);
Asserts.assertTrue(result);
}
@Test()
public boolean test42(Class c, MyValue1? vt) {
@@ -765,13 +765,13 @@
}
@DontCompile
public void test42_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
- boolean result = test42(MyValue2.class.asBoxType(), vt);
+ boolean result = test42(MyValue2.class.asNullableType(), vt);
Asserts.assertFalse(result);
- result = test42(MyValue2.class.asValueType(), vt);
+ result = test42(MyValue2.class.asPrimaryType(), vt);
Asserts.assertFalse(result);
}
// Class.cast
@Test()
@@ -780,13 +780,13 @@
}
@DontCompile
public void test43_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
- Object result = test43(MyValue1.class.asBoxType(), vt);
+ Object result = test43(MyValue1.class.asNullableType(), vt);
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
- result = test43(MyValue1.class.asBoxType(), null);
+ result = test43(MyValue1.class.asNullableType(), null);
Asserts.assertEQ(result, null);
}
@Test()
public Object test44(Class c, MyValue1? vt) {
@@ -795,19 +795,19 @@
@DontCompile
public void test44_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
try {
- test44(MyValue2.class.asBoxType(), vt);
+ test44(MyValue2.class.asNullableType(), vt);
throw new RuntimeException("should have thrown");
} catch (ClassCastException cce) {
}
}
@Test()
public Object test45(MyValue1? vt) {
- return MyValue1.class.asBoxType().cast(vt);
+ return MyValue1.class.asNullableType().cast(vt);
}
@DontCompile
public void test45_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -817,11 +817,11 @@
Asserts.assertEQ(result, null);
}
@Test()
public Object test46(MyValue1? vt) {
- return MyValue2.class.asBoxType().cast(vt);
+ return MyValue2.class.asNullableType().cast(vt);
}
@DontCompile
public void test46_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -833,11 +833,11 @@
}
}
@Test()
public Object test47(MyValue1? vt) {
- return MyValue1.class.asValueType().cast(vt);
+ return MyValue1.class.asPrimaryType().cast(vt);
}
@DontCompile
public void test47_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -856,22 +856,22 @@
}
@DontCompile
public void test48_verifier(boolean warmup) {
MyValue1? vt = MyValue1.createWithFieldsInline(rI, rL);
- Object result = test48(MyValue1.class.asValueType(), vt);
+ Object result = test48(MyValue1.class.asPrimaryType(), vt);
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
try {
- test48(MyValue1.class.asValueType(), null);
+ test48(MyValue1.class.asPrimaryType(), null);
throw new RuntimeException("should have thrown");
} catch (NullPointerException npe) {
}
}
@Test()
public Object test49(MyValue1 vt) {
- return MyValue1.class.asBoxType().cast(vt);
+ return MyValue1.class.asNullableType().cast(vt);
}
@DontCompile
public void test49_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
@@ -887,22 +887,22 @@
@DontCompile
public void test50_verifier(boolean warmup) {
MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
MyValue1[] va = new MyValue1[42];
MyValue1?[] vba = new MyValue1?[42];
- Object result = test50(MyValue1.class.asValueType(), vt);
+ Object result = test50(MyValue1.class.asPrimaryType(), vt);
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
- result = test50(MyValue1.class.asBoxType(), vt);
+ result = test50(MyValue1.class.asNullableType(), vt);
Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
result = test50(MyValue1[].class, va);
Asserts.assertEQ(result, va);
result = test50(MyValue1?[].class, vba);
Asserts.assertEQ(result, vba);
result = test50(MyValue1?[].class, va);
Asserts.assertEQ(result, va);
try {
- test50(MyValue1.class.asValueType(), null);
+ test50(MyValue1.class.asPrimaryType(), null);
throw new RuntimeException("should have thrown");
} catch (NullPointerException npe) {
}
try {
test50(MyValue1[].class, vba);
@@ -912,11 +912,11 @@
}
// value type array creation via reflection
@Test()
public void test51(int len) {
- Object[] va = (Object[])Array.newInstance(MyValue1.class.asBoxType().asValueType().asBoxType(), len);
+ Object[] va = (Object[])Array.newInstance(MyValue1.class.asNullableType().asPrimaryType().asNullableType(), len);
for (int i = 0; i < len; ++i) {
Asserts.assertEQ(va[i], null);
}
}
< prev index next >