test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java Fri Jun 16 14:34:20 2017
--- new/test/compiler/valhalla/valuetypes/ValueTypeTestBench.java Fri Jun 16 14:34:20 2017
*** 564,573 ****
--- 564,575 ----
private static final MethodHandle vccUnboxBoxLoadIntMH = generateVCCUnboxBoxLoadIntMH();
private static final MethodHandle nullvccUnboxLoadLongMH = generateNullVCCUnboxLoadLongMH();
private static final MethodHandle objectUnboxLoadLongMH = generateObjectUnboxLoadLongMH();
private static final MethodHandle objectBoxMH = generateObjectBoxMH();
private static final MethodHandle checkedvccUnboxLoadLongMH = generateCheckedVCCUnboxLoadLongMH();
+ private static final MethodHandle vastoreMH = generateVastore();
+ private static final MethodHandle invalidVastoreMH = generateInvalidVastore();
private static final ValueCapableClass1 vcc = ValueCapableClass1.create(rL, rI, (short)rI, (short)rI);
private static final ValueCapableClass2 vcc2 = ValueCapableClass2.create(rL + 1);
// ========== Helper methods ==========
*** 767,777 ****
--- 769,779 ----
long result = test11(rI, rL);
Asserts.assertEQ(result, hash(rI + 10, rL + 10));
}
// Test loop with uncommon trap referencing a value type
! @Test(match = {TRAP, SCOBJ}, matchCount = {1, -1 /* at least 1 */}, failOn = LOAD)
public long test12(boolean b) {
MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
MyValue1[] va = new MyValue1[Math.abs(rI) % 10];
for (int i = 0; i < va.length; ++i) {
va[i] = MyValue1.createWithFieldsInline(rI, rL);
*** 797,807 ****
--- 799,809 ----
long result = test12(warmup);
Asserts.assertEQ(result, warmup ? rL + (1000 * rI) : ((Math.abs(rI) % 10) + 1) * hash());
}
// Test loop with uncommon trap referencing a value type
- @Test(match = {TRAP}, matchCount = {1})
public long test13(boolean b) {
MyValue1 v = MyValue1.createWithFieldsDontInline(rI, rL);
MyValue1[] va = new MyValue1[Math.abs(rI) % 10];
for (int i = 0; i < va.length; ++i) {
va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
*** 1435,1445 ****
--- 1437,1447 ----
Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i));
}
}
// Merge value type arrays created from two branches
- @Test(failOn = (TRAP))
public MyValue1[] test45(boolean b) {
MyValue1[] va;
if (b) {
va = new MyValue1[5];
for (int i = 0; i < 5; ++i) {
*** 2159,2168 ****
--- 2161,2372 ----
} catch (NoSuchMethodException|IllegalAccessException e) {
throw new RuntimeException("method handle lookup fails");
}
}
+ /* Array load out of bounds (upper bound) at compile time.*/
+ @Test
+ public int test77() {
+ int arraySize = Math.abs(rI) % 10;;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ for (int i = 0; i < arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI + 1, rL);
+ }
+
+ try {
+ return va[arraySize + 1].x;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return rI;
+ }
+ }
+
+ public void test77_verifier(boolean warmup) {
+ Asserts.assertEQ(test77(), rI);
+ }
+
+ /* Array load out of bounds (lower bound) at compile time.*/
+ @Test
+ public int test78() {
+ int arraySize = Math.abs(rI) % 10;;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ for (int i = 0; i < arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL);
+ }
+
+ try {
+ return va[-arraySize].x;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return rI;
+ }
+ }
+
+ public void test78_verifier(boolean warmup) {
+ Asserts.assertEQ(test78(), rI);
+ }
+
+ /* Array load out of bound not known to compiler (both lower and upper bound). */
+ @Test
+ public int test79(MyValue1[] va, int index) {
+ return va[index].x;
+ }
+
+ public void test79_verifier(boolean warmup) {
+ int arraySize = Math.abs(rI) % 10;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ for (int i = 0; i < arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
+ }
+
+ int result;
+ for (int i = -20; i < 20; i++) {
+ try {
+ result = test79(va, i);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ result = rI;
+ }
+ Asserts.assertEQ(result, rI);
+ }
+ }
+
+ /* Array store out of bounds (upper bound) at compile time.*/
+ @Test
+ public int test80() {
+ int arraySize = Math.abs(rI) % 10;;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ try {
+ for (int i = 0; i <= arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI + 1, rL);
+ }
+ return rI - 1;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return rI;
+ }
+ }
+
+ public void test80_verifier(boolean warmup) {
+ Asserts.assertEQ(test80(), rI);
+ }
+
+ /* Array store out of bounds (lower bound) at compile time.*/
+ @Test
+ public int test81() {
+ int arraySize = Math.abs(rI) % 10;;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ try {
+ for (int i = -1; i <= arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI + 1, rL);
+ }
+ return rI - 1;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ return rI;
+ }
+ }
+
+ public void test81_verifier(boolean warmup) {
+ Asserts.assertEQ(test81(), rI);
+ }
+
+ /* Array store out of bound not known to compiler (both lower and upper bound). */
+ @Test
+ public int test82(MyValue1[] va, int index, MyValue1 vt) {
+ va[index] = vt;
+ return va[index].x;
+ }
+
+ @DontCompile
+ public void test82_verifier(boolean warmup) {
+ int arraySize = Math.abs(rI) % 10;
+ MyValue1[] va = new MyValue1[arraySize];
+
+ for (int i = 0; i < arraySize; i++) {
+ va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
+ }
+
+ MyValue1 vt = MyValue1.createWithFieldsDontInline(rI + 1, rL);
+ int result;
+ for (int i = -20; i < 20; i++) {
+ try {
+ result = test82(va, i, vt);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ result = rI + 1;
+ }
+ Asserts.assertEQ(result, rI + 1);
+ }
+
+ for (int i = 0; i < arraySize; i++) {
+ Asserts.assertEQ(va[i].x, rI + 1);
+ }
+ }
+
+ /* Create a new value type array and store a value type into
+ * it. The test should pass without throwing an exception. */
+ @Test
+ public void test83() throws Throwable {
+ vastoreMH.invokeExact(vcc);
+ }
+
+ public void test83_verifier(boolean warmup) throws Throwable {
+ test83();
+ }
+
+ private static MethodHandle generateVastore() {
+ return MethodHandleBuilder.loadCode(MethodHandles.lookup(),
+ "Vastore",
+ MethodType.methodType(void.class, ValueCapableClass1.class),
+ CODE -> {
+ CODE.
+ iconst_1().
+ anewarray(ValueType.forClass(ValueCapableClass1.class).valueClass()).
+ iconst_0().
+ aload_0().
+ vunbox(ValueType.forClass(ValueCapableClass1.class).valueClass()).
+ vastore().
+ return_();
+ }
+ );
+ }
+
+ /* Create a new value type array with element type
+ * ValueCapableClass1 and attempt to store a value type of type
+ * ValueCapableClass2 into it. */
+ @Test
+ public void test84() throws Throwable {
+ invalidVastoreMH.invokeExact(vcc2);
+ }
+
+ public void test84_verifier(boolean warmup) throws Throwable {
+ boolean exceptionThrown = false;
+ try {
+ test84();
+ } catch (ArrayStoreException e) {
+ exceptionThrown = true;
+ }
+ Asserts.assertTrue(exceptionThrown, "ArrayStoreException must be thrown");
+ }
+
+ private static MethodHandle generateInvalidVastore() {
+ return MethodHandleBuilder.loadCode(MethodHandles.lookup(),
+ "Vastore",
+ MethodType.methodType(void.class, ValueCapableClass2.class),
+ CODE -> {
+ CODE.
+ iconst_1().
+ anewarray(ValueType.forClass(ValueCapableClass1.class).valueClass()).
+ iconst_0().
+ aload_0().
+ vunbox(ValueType.forClass(ValueCapableClass2.class).valueClass()).
+ vastore().
+ return_();
+ }
+ );
+ }
+
// ========== Test infrastructure ==========
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
private static final int ValueTypePassFieldsAsArgsOn = 0x1;
private static final int ValueTypePassFieldsAsArgsOff = 0x2;
*** 2233,2243 ****
--- 2437,2447 ----
System.out.println("WARNING: IR verification disabled! Running with -Xint, -Xcomp or release build?");
}
}
public static void main(String[] args) throws Throwable {
! //tests.values().removeIf(p -> !p.getName().equals("test74")); // Run single test
! //tests.values().removeIf(p -> !p.getName().equals("test85")); // Run single test
if (args.length == 0) {
execute_vm("-XX:+IgnoreUnrecognizedVMOptions", "-XX:-BackgroundCompilation",
"-XX:+PrintCompilation", "-XX:+PrintInlining", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
"-XX:CICompilerCount=1",
"-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*",
test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File