< prev index next >

test/compiler/valhalla/valuetypes/ValueTypeTestBench.java

Print this page

        

*** 2726,2735 **** --- 2726,2760 ---- int.class)); test102_mh = MethodHandles.collectArguments(test102_getfield, 0, MethodHandles.countedLoop(test102_count, test102_init, test102_body)); + MethodType test103_mt = MethodType.fromMethodDescriptorString("()Qcompiler/valhalla/valuetypes/MyValue3;", ValueTypeTestBench.class.getClassLoader()); + MethodHandle test103_mh1 = lookup.findVirtual(ValueTypeTestBench.class, "test103_target1", test103_mt); + MethodHandle test103_mh2 = lookup.findVirtual(ValueTypeTestBench.class, "test103_target2", test103_mt); + MethodHandle test103_mh3 = lookup.findVirtual(ValueTypeTestBench.class, "test103_target3", test103_mt); + MethodType test103_mt2 = MethodType.methodType(boolean.class); + MethodHandle test103_mh_test1 = lookup.findVirtual(ValueTypeTestBench.class, "test103_test1", test103_mt2); + MethodHandle test103_mh_test2 = lookup.findVirtual(ValueTypeTestBench.class, "test103_test2", test103_mt2); + test103_mh = MethodHandles.guardWithTest(test103_mh_test1, + test103_mh1, + MethodHandles.guardWithTest(test103_mh_test2, test103_mh2, test103_mh3)); + + MethodType test104_mt = MethodType.fromMethodDescriptorString("()Qcompiler/valhalla/valuetypes/MyValue2;", ValueTypeTestBench.class.getClassLoader()); + MethodHandle test104_mh1 = lookup.findStatic(ValueTypeTestBench.class, "test104_target1", test104_mt); + test104_mh2 = lookup.findStatic(ValueTypeTestBench.class, "test104_target2", test104_mt); + test104_mh3 = lookup.findStatic(ValueTypeTestBench.class, "test104_target3", test104_mt); + MethodType test104_mt2 = MethodType.methodType(boolean.class); + MethodType test104_mt3 = MethodType.fromMethodDescriptorString("()Qcompiler/valhalla/valuetypes/MyValue2;", ValueTypeTestBench.class.getClassLoader()); + MethodHandle test104_mh_test1 = lookup.findStatic(ValueTypeTestBench.class, "test104_test1", test104_mt2); + MethodHandle test104_mh_test2 = lookup.findStatic(ValueTypeTestBench.class, "test104_test2", test104_mt2); + test104_mh = MethodHandles.guardWithTest(test104_mh_test1, + MethodHandles.dropArguments(test104_mh1, 0, MethodHandle.class, MethodHandle.class), + MethodHandles.guardWithTest(test104_mh_test2, + MethodHandles.dropArguments(MethodHandles.invoker(test104_mt3), 1, MethodHandle.class), + MethodHandles.dropArguments(MethodHandles.invoker(test104_mt3), 0, MethodHandle.class)) + ); } catch (NoSuchMethodException|IllegalAccessException|NoSuchFieldException e) { e.printStackTrace(); throw new RuntimeException("method handle lookup fails"); } }
*** 2768,2778 **** MyValue3 vt = test99(); vt.verify(test99_bool ? test99_vt1 : test99_vt2); } // Similar as above but with the method handle for target1 not ! // constant. Shouldn't cause any allocation but does currently. @ForceInline static MyValue2 test100_target1() { return MyValue2.createWithFieldsInline(rI, true); } --- 2793,2803 ---- MyValue3 vt = test99(); vt.verify(test99_bool ? test99_vt1 : test99_vt2); } // Similar as above but with the method handle for target1 not ! // constant. Shouldn't cause any allocation. @ForceInline static MyValue2 test100_target1() { return MyValue2.createWithFieldsInline(rI, true); }
*** 2788,2798 **** } static final MethodHandle test100_mh; static MethodHandle test100_mh1; ! @Test long test100() throws Throwable { return ((MyValue2)test100_mh.invokeExact(test100_mh1)).hash(); } @DontCompile --- 2813,2824 ---- } static final MethodHandle test100_mh; static MethodHandle test100_mh1; ! @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE) ! @Test(valid = ValueTypeReturnedAsFieldsOff) long test100() throws Throwable { return ((MyValue2)test100_mh.invokeExact(test100_mh1)).hash(); } @DontCompile
*** 2801,2811 **** long hash = test100(); Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(rI+(test100_bool ? 0 : 1), test100_bool).hash()); } // Same as above but with the method handle for target2 not ! // constant. Shouldn't cause any allocation but does currently. @ForceInline static MyValue2 test101_target1() { return MyValue2.createWithFieldsInline(rI, true); } --- 2827,2837 ---- long hash = test100(); Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(rI+(test100_bool ? 0 : 1), test100_bool).hash()); } // Same as above but with the method handle for target2 not ! // constant. Shouldn't cause any allocation. @ForceInline static MyValue2 test101_target1() { return MyValue2.createWithFieldsInline(rI, true); }
*** 2821,2831 **** } static final MethodHandle test101_mh; static MethodHandle test101_mh2; ! @Test long test101() throws Throwable { return ((MyValue2)test101_mh.invokeExact(test101_mh2)).hash(); } @DontCompile --- 2847,2858 ---- } static final MethodHandle test101_mh; static MethodHandle test101_mh2; ! @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE) ! @Test(valid = ValueTypeReturnedAsFieldsOff) long test101() throws Throwable { return ((MyValue2)test101_mh.invokeExact(test101_mh2)).hash(); } @DontCompile
*** 2848,2857 **** --- 2875,2985 ---- @DontCompile public void test102_verifier(boolean warmup) throws Throwable { long v = test102(); Asserts.assertEQ(v, 100L); } + + // Return of target1, target2 and target3 merged in Lambda Forms + // as an __Value. Shouldn't cause any allocation + final MyValue3 test103_vt1 = MyValue3.create(); + @ForceInline + MyValue3 test103_target1() { + return test103_vt1; + } + + final MyValue3 test103_vt2 = MyValue3.create(); + @ForceInline + MyValue3 test103_target2() { + return test103_vt2; + } + + final MyValue3 test103_vt3 = MyValue3.create(); + @ForceInline + MyValue3 test103_target3() { + return test103_vt3; + } + + boolean test103_bool1 = true; + @ForceInline + boolean test103_test1() { + return test103_bool1; + } + + boolean test103_bool2 = true; + @ForceInline + boolean test103_test2() { + return test103_bool2; + } + + static final MethodHandle test103_mh; + + @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE) + @Test(valid = ValueTypeReturnedAsFieldsOff) + MyValue3 test103() throws Throwable { + return (MyValue3)test103_mh.invokeExact(this); + } + + static int test103_i = 0; + @DontCompile + public void test103_verifier(boolean warmup) throws Throwable { + test103_i++; + test103_bool1 = (test103_i % 2) == 0; + test103_bool2 = (test103_i % 3) == 0; + MyValue3 vt = test103(); + vt.verify(test103_bool1 ? test103_vt1 : (test103_bool2 ? test103_vt2 : test103_vt3)); + } + + // Same as above but with non constant target2 and target3 + @ForceInline + static MyValue2 test104_target1() { + return MyValue2.createWithFieldsInline(rI, true); + } + + @ForceInline + static MyValue2 test104_target2() { + return MyValue2.createWithFieldsInline(rI+1, false); + } + + @ForceInline + static MyValue2 test104_target3() { + return MyValue2.createWithFieldsInline(rI+2, true); + } + + static boolean test104_bool1 = true; + @ForceInline + static boolean test104_test1() { + return test104_bool1; + } + + static boolean test104_bool2 = true; + @ForceInline + static boolean test104_test2() { + return test104_bool2; + } + + static final MethodHandle test104_mh; + static MethodHandle test104_mh2; + static MethodHandle test104_mh3; + + @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE) + @Test(valid = ValueTypeReturnedAsFieldsOff) + long test104() throws Throwable { + return ((MyValue2)test104_mh.invokeExact(test104_mh2, test104_mh3)).hash(); + } + + static int test104_i = 0; + @DontCompile + public void test104_verifier(boolean warmup) throws Throwable { + test104_i++; + test104_bool1 = (test104_i % 2) == 0; + test104_bool2 = (test104_i % 3) == 0; + long hash = test104(); + int i = rI+(test104_bool1 ? 0 : (test104_bool2 ? 1 : 2)); + boolean b = test104_bool1 ? true : (test104_bool2 ? false : true); + Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(i, b).hash()); + } + // ========== 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 >