Dirt-simple dynamic dispatch bootstrapper built into JDK?

Charles Oliver Nutter headius at headius.com
Mon Mar 22 22:17:23 PDT 2010


Hey, maybe I missed something, but it seems like there's a need for a
"default" invokedynamic bootstrap. For example, I hacked invokedynamic
bytecode emitting into Duby, so that this code:

def foo(a:dynamic)
  a.size
  a.elementAt(0)
end

Emits this bytecode:

  public static java.lang.Object foo(java.lang.Object);
    Code:
       0: aload_0
       1: invokedynamic #10,  0             // NameAndType
size:(Ljava/lang/Object;)Ljava/lang/Object;
       6: pop
       7: aload_0
       8: iconst_1
       9: invokedynamic #13,  0             // NameAndType
elementAt:(Ljava/lang/Object;I)Ljava/lang/Object;
      14: areturn

Now rather than me shipping my own bootstrapper that just does normal
Java method selection, it would be nice if there were one built into
the JDK. It seems like a lot of folks playing with invokedynamic will
want a simple fallback that just does Java invocation.

Is there anything like this in indy right now?

* Take the signature (minus the passed java/lang/Object) and try to
look up a method on the actual target
* If that fails, use the actual types of the arguments to perform the
same search
* If that fails, throw some interesting runtime error
* If we find a method, bind it with a simple class equality type guard
* Stack bindings for additional classes as they are encountered
possibly caching at a JVM level the sets of target+args we've seen

- Charlie


More information about the mlvm-dev mailing list