< prev index next >

test/compiler/valhalla/valuetypes/ValueTypeTestBench.java

Print this page

        

@@ -2144,11 +2144,11 @@
             return test76_vt;
         }
     }
 
     @DontCompile
-    public void test76_verifier(boolean warmup) throws Exception {
+    public void test76_verifier(boolean warmup) {
         MyValue3 vt = test76();
         test76_vt.verify(vt);
     }
 
     static {

@@ -2363,10 +2363,71 @@
                         return_();
                }
                 );
     }
 
+    // When test85_helper1 is inlined in test85, the method handle
+    // linker that called it is passed a pointer to a copy of vt
+    // stored in memory. The method handle linker needs to load the
+    // fields from memory before it inlines test85_helper1.
+    static public int test85_helper1(MyValue1 vt) {
+        return vt.x;
+    }
+
+    static MyValue1 test85_vt = MyValue1.createWithFieldsInline(rI, rL);
+    static public MyValue1 test85_helper2() {
+        return test85_vt;
+    }
+
+    static final MethodHandle test85_mh;
+
+    @Test
+    public int test85() throws Throwable {
+        return (int)test85_mh.invokeExact();
+    }
+
+    @DontCompile
+    public void test85_verifier(boolean warmup) throws Throwable {
+        int i = test85();
+        Asserts.assertEQ(i, test85_vt.x);
+    }
+
+    // Test method handle call with value type argument
+    public int test86_target(MyValue1 vt) {
+        return vt.x;
+    }
+
+    static final MethodHandle test86_mh;
+    MyValue1 test86_vt = MyValue1.createWithFieldsInline(rI, rL);
+
+    @Test
+    public int test86() throws Throwable {
+        return (int)test86_mh.invokeExact(this, test86_vt);
+    }
+
+    @DontCompile
+    public void test86_verifier(boolean warmup) throws Throwable {
+        int i = test86();
+        Asserts.assertEQ(i, test86_vt.x);
+    }
+
+    static {
+        try {
+            MethodHandles.Lookup lookup = MethodHandles.lookup();
+
+            MethodType test85_mt1 = MethodType.fromMethodDescriptorString("(Qcompiler/valhalla/valuetypes/MyValue1;)I", ValueTypeTestBench.class.getClassLoader());
+            MethodType test85_mt2 = MethodType.fromMethodDescriptorString("()Qcompiler/valhalla/valuetypes/MyValue1;", ValueTypeTestBench.class.getClassLoader());
+            MethodHandle test85_mh1 = lookup.findStatic(ValueTypeTestBench.class, "test85_helper1", test85_mt1);
+            MethodHandle test85_mh2 = lookup.findStatic(ValueTypeTestBench.class, "test85_helper2", test85_mt2);
+            test85_mh = MethodHandles.filterReturnValue(test85_mh2, test85_mh1);
+
+            MethodType test86_mt = MethodType.fromMethodDescriptorString("(Qcompiler/valhalla/valuetypes/MyValue1;)I", ValueTypeTestBench.class.getClassLoader());
+            test86_mh = lookup.findVirtual(ValueTypeTestBench.class, "test86_target", test86_mt);
+        } catch (NoSuchMethodException|IllegalAccessException e) {
+            throw new RuntimeException("method handle lookup fails");
+        }
+    }
     // ========== 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 >