Duby dynamic dispatch has landed!

John Rose John.Rose at Sun.COM
Wed Mar 24 21:48:18 PDT 2010


Very nice stuff.  Congratulations!

On Mar 24, 2010, at 7:17 PM, Charles Oliver Nutter wrote:

> BTW, what's the current state of the art for emitting .java with an
> invokedynamic in it? Duby also has a .java backend, so I'll need to
> add indy support there as well (somehow).

This statement:

	java.dyn.InvokeDynamic.<boolean>#"foo:bar"(1, 2.3, (Object)four);

compiles to code ending in this instruction:

	invokedynamic "foo:bar", (IDLjava/lang/Object;)Z

...and so forth.

At the source level, java.dyn.InvokeDynamic appears to have an infinity of named static methods, each fully signature-polymorphic.

Similarly, the two methods named "invokeExact" and "invokeGeneric" in java.dyn.MethodHandle are also signature-polymorphic:

	myMH.<void>invokeExact();
	myMH.<String>invokeGeneric('c');

Calls to those methods compile to ordinary looking invokevirtual instructions, but with arbitrary signatures:

	invokevirtual java/dyn/MethodHandle, invokeExact, ()V
	invokevirtual java/dyn/MethodHandle, invokeGeneric, (C)Ljava/lang/String;

The latest new 292 feature affecting code generation is "ldc" of method handles and method types.  For source code examples, see this file:

	test/tools/javac/meth/MHLiterals.java

in this patch:

	http://hg.openjdk.java.net/mlvm/mlvm/langtools/file/tip/meth-ldc.patch

Finally, watch out for incompatible changes on the way.  We are downsizing CallSite, which is an incompatible change.  For updated use of CallSite, see examples such as this one (which turn out to be simpler):

	http://hg.openjdk.java.net/mlvm/mlvm/file/tip/netbeans/indy-demo/src/PrintArgsDemo.java

-- John


More information about the mlvm-dev mailing list