< prev index next >
test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
Print this page
*** 2564,2573 ****
--- 2564,2612 ----
Asserts.assertEQ(staticVal3.i, (int)staticVal3.c);
Asserts.assertEQ(va[0].i, (int)staticVal3.c);
Asserts.assertEQ(vt.i, (int)staticVal3.c);
}
+ // Test correct handling of __Value merges through PhiNodes
+ @Test()
+ public long test93() throws Throwable {
+ // Create a new value type
+ final MethodHandle dvt = MethodHandleBuilder.loadCode(MethodHandles.lookup(), "createValueType",
+ MethodType.methodType(ValueType.forClass(ValueCapableClass1.class).valueClass()),
+ CODE -> {
+ CODE.
+ iconst_1().
+ anewarray(ValueType.forClass(ValueCapableClass1.class).valueClass()).
+ iconst_0().
+ vaload().
+ vreturn();
+ });
+ // Box the value type
+ final MethodHandle box = MethodHandleBuilder.loadCode(MethodHandles.lookup(), "boxValueType",
+ MethodType.methodType(ValueCapableClass1.class, ValueType.forClass(ValueCapableClass1.class).valueClass()),
+ CODE -> {
+ CODE.
+ vload(0).
+ vbox(ValueCapableClass1.class).
+ areturn();
+ });
+ long result = 0;
+ for (int i = 0; i < 10_000; ++i) {
+ // Merge __Value (ValueCapableClass1) from the two GWT branches, box to the VCC and access field
+ MethodHandle gwt = MethodHandles.guardWithTest(MethodHandles.constant(boolean.class, i % 2 == 0), dvt, dvt);
+ ValueCapableClass1 vcc = (ValueCapableClass1) MethodHandles.filterReturnValue(gwt, box).invokeExact();
+ result += vcc.t;
+ }
+ return result;
+ }
+
+ @DontCompile
+ public void test93_verifier(boolean warmup) throws Throwable {
+ long result = test93();
+ Asserts.assertEQ(result, 0L);
+ }
+
// ========== Test infrastructure ==========
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
private static final int ValueTypePassFieldsAsArgsOn = 0x1;
private static final int ValueTypePassFieldsAsArgsOff = 0x2;
< prev index next >