FYI, here's the patch against JRuby invokedynamic branch to update all "test" handles to a single Java method wrapped by dropArguments (attached).

Charles Oliver Nutter wrote:
I saw jrose land a dropArguments fix a day or two ago, but it still seems to be coming up NYI for me:

~/projects/jruby ➔ JAVA_HOME=$MLVM_HOME JAVA_OPTS=$INDY_OPTS jruby -d -e "puts 1"
could not compile: -e because of: "null"
java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:186)
at org.jruby.compiler.impl.StandardASMCompiler.<clinit>(StandardASMCompiler.java:127)
        at org.jruby.Ruby.tryCompile(Ruby.java:536)
        at org.jruby.Ruby.tryCompile(Ruby.java:524)
        at org.jruby.Ruby.runNormally(Ruby.java:505)
        at org.jruby.Ruby.runFromMain(Ruby.java:361)
        at org.jruby.Main.run(Main.java:268)
        at org.jruby.Main.run(Main.java:113)
        at org.jruby.Main.main(Main.java:97)
Caused by: java.lang.UnsupportedOperationException: NYI
        at sun.dyn.MethodHandleImpl.dropArguments(MethodHandleImpl.java:301)
        at java.dyn.MethodHandles.dropArguments(MethodHandles.java:1021)
at org.jruby.runtime.invokedynamic.InvokeDynamicSupport.<clinit>(InvokeDynamicSupport.java:388)

Here's the code in syn/dyn/MethodHandleImpl.java:

     public static
     MethodHandle dropArguments(Access token, MethodHandle target,
                                MethodType newType, int argnum) {
         Access.check(token);
         throw new UnsupportedOperationException("NYI");
     }

I certainly could have things applied incorrectly, but I could find no updates to MethodHandleImpl.java in patches/jdk/indy.patch

- Charlie
_______________________________________________
mlvm-dev mailing list
[email protected]
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

diff --git a/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java 
b/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
index 332d1c1..a83ebfe 100644
--- a/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
+++ b/src/org/jruby/runtime/invokedynamic/InvokeDynamicSupport.java
@@ -72,7 +72,7 @@ public class InvokeDynamicSupport {
         return MethodHandles.convertArguments(guardWithTest, site.type());
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name) {
+    public static boolean test(CacheEntry entry, IRubyObject self) {
         return entry.typeOk(self.getMetaClass());
     }
 
@@ -92,10 +92,6 @@ public class InvokeDynamicSupport {
         return entry.method.call(context, self, selfClass, name);
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0) {
         RubyClass selfClass = pollAndGetClass(context, self);
         return entry.method.call(context, self, selfClass, name, arg0);
@@ -112,10 +108,6 @@ public class InvokeDynamicSupport {
         return entry.method.call(context, self, selfClass, name, arg0);
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1) {
         RubyClass selfClass = pollAndGetClass(context, self);
         return entry.method.call(context, self, selfClass, name, arg0, arg1);
@@ -132,10 +124,6 @@ public class InvokeDynamicSupport {
         return entry.method.call(context, self, selfClass, name, arg0, arg1);
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, IRubyObject arg2) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, IRubyObject arg2) {
         RubyClass selfClass = pollAndGetClass(context, self);
         return entry.method.call(context, self, selfClass, name, arg0, arg1, 
arg2);
@@ -172,10 +160,6 @@ public class InvokeDynamicSupport {
         return entry.method.call(context, self, selfClass, name, args);
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, Block block) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, Block block) {
         try {
             RubyClass selfClass = pollAndGetClass(context, self);
@@ -208,10 +192,6 @@ public class InvokeDynamicSupport {
         }
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, Block 
block) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, Block 
block) {
         try {
             RubyClass selfClass = pollAndGetClass(context, self);
@@ -244,10 +224,6 @@ public class InvokeDynamicSupport {
         }
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, Block block) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, Block block) {
         try {
             RubyClass selfClass = pollAndGetClass(context, self);
@@ -280,10 +256,6 @@ public class InvokeDynamicSupport {
         }
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, IRubyObject arg2, Block block) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject arg0, 
IRubyObject arg1, IRubyObject arg2, Block block) {
         try {
             RubyClass selfClass = pollAndGetClass(context, self);
@@ -316,10 +288,6 @@ public class InvokeDynamicSupport {
         }
     }
 
-    public static boolean test(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject[] args, Block 
block) {
-        return entry.typeOk(self.getMetaClass());
-    }
-
     public static IRubyObject target(CacheEntry entry, ThreadContext context, 
IRubyObject caller, IRubyObject self, String name, IRubyObject[] args, Block 
block) {
         try {
             RubyClass selfClass = pollAndGetClass(context, self);
@@ -417,71 +385,67 @@ public class InvokeDynamicSupport {
     private static final MethodType BOOTSTRAP_TYPE = 
MethodType.make(CallSite.class, Class.class, String.class, MethodType.class);
     private static final MethodHandle BOOTSTRAP = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "bootstrap", 
BOOTSTRAP_TYPE);
 
-    private static final MethodHandle TEST_0 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class));
+    private static final MethodHandle TEST = MethodHandles.dropArguments(
+            MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, 
"test",
+                MethodType.make(boolean.class, CacheEntry.class, 
IRubyObject.class)),
+            1,
+            ThreadContext.class, IRubyObject.class);
+
+    private static final MethodHandle TEST_0 = 
MethodHandles.dropArguments(TEST, 2, String.class);
     private static final MethodHandle TARGET_0 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class));
     private static final MethodHandle FALLBACK_0 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class));
 
-    private static final MethodHandle TEST_1 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class));
+    private static final MethodHandle TEST_1 = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class);
     private static final MethodHandle TARGET_1 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class));
     private static final MethodHandle FALLBACK_1 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class));
 
-    private static final MethodHandle TEST_2 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class));
+    private static final MethodHandle TEST_2 = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class, 
IRubyObject.class);
     private static final MethodHandle TARGET_2 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class));
     private static final MethodHandle FALLBACK_2 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class));
 
-    private static final MethodHandle TEST_3 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class));
+    private static final MethodHandle TEST_3 = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class, 
IRubyObject.class, IRubyObject.class);
     private static final MethodHandle TARGET_3 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class));
     private static final MethodHandle FALLBACK_3 = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class));
 
-    private static final MethodHandle TEST_N = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject[].class));
+    private static final MethodHandle TEST_N = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject[].class);
     private static final MethodHandle TARGET_N = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject[].class));
     private static final MethodHandle FALLBACK_N = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject[].class));
 
-    private static final MethodHandle TEST_0_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
Block.class));
+    private static final MethodHandle TEST_0_B = 
MethodHandles.dropArguments(TEST, 2, String.class, Block.class);
     private static final MethodHandle TARGET_0_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
Block.class));
     private static final MethodHandle FALLBACK_0_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
Block.class));
 
-    private static final MethodHandle TEST_1_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, Block.class));
+    private static final MethodHandle TEST_1_B = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class, 
Block.class);
     private static final MethodHandle TARGET_1_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, Block.class));
     private static final MethodHandle FALLBACK_1_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, Block.class));
 
-    private static final MethodHandle TEST_2_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, Block.class));
+    private static final MethodHandle TEST_2_B = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class, 
IRubyObject.class, Block.class);
     private static final MethodHandle TARGET_2_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, Block.class));
     private static final MethodHandle FALLBACK_2_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, Block.class));
 
-    private static final MethodHandle TEST_3_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class, Block.class));
+    private static final MethodHandle TEST_3_B = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject.class, 
IRubyObject.class, IRubyObject.class, Block.class);
     private static final MethodHandle TARGET_3_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class, Block.class));
     private static final MethodHandle FALLBACK_3_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
             MethodType.make(IRubyObject.class, JRubyCallSite.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject.class, IRubyObject.class, IRubyObject.class, Block.class));
 
-    private static final MethodHandle TEST_N_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "test",
-            MethodType.make(boolean.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject[].class, Block.class));
+    private static final MethodHandle TEST_N_B = 
MethodHandles.dropArguments(TEST, 2, String.class, IRubyObject[].class, 
Block.class);
     private static final MethodHandle TARGET_N_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "target",
             MethodType.make(IRubyObject.class, CacheEntry.class, 
ThreadContext.class, IRubyObject.class, IRubyObject.class, String.class, 
IRubyObject[].class, Block.class));
     private static final MethodHandle FALLBACK_N_B = 
MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback",
_______________________________________________
mlvm-dev mailing list
[email protected]
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to