Simple dynamic language using invokedynamic
Rémi Forax
forax at univ-mlv.fr
Mon Jun 22 01:02:56 PDT 2009
Chanwit Kaewkasi a écrit :
> Hi,
>
> Following Juby, my language "G7" is a Groovy-like language that also
> compiles to invokedynamic ;-)
> I use Groovy parser, remove its MOP layer and rewrite the code
> generation class. The idea of wiring up invokedynamic is taken from
> Juby implementation.
>
> It runs on JDK 7-b61 and it is just enough to compile Fibonacci and
> some simple programs.
> Unfortunately, MethodHandles.collectArguments, and dropArguments are
> still NIY in b61. So, I separated fallback into 4 handles, rather than
> having the single fallback.
>
> Another thing is that I successfully made a call to static using the
> trick from John's blog by encoding callsite names with the
> "static:<class>:<method>" pattern.
>
> Here is its GIT repository:
> http://github.com/chanwit/g7/tree/parser
>
> For a quick look:
> http://gist.github.com/133661
>
> Anyway, the Fib program can run Fib(31) successfully, but JVM crashes
> when I run Fib(32) and Fib(35).
>
> Chanwit
>
Hi Chanwit,
run with -Xint, the JIT doesn't work in b61,
I think it should work with latest patches from mlvm repo.
About your generated code, you use BIPUSH 1 instead of ICONST_1
and in the static initializer, you can use LDC with a class (a Type in ASM)
instead of loading a String and relying on Class.forName().
What disassembler do you use ?
I have noticed that INVOKEDYNAMIC is printed with a receiver
an I fear I have forget to patch that in ASM sources.
This week end, I have hacked the backport to be able to run invokedynamic,
Could you please try to run your example with it ?
Donwload it here:
http://code.google.com/p/jvm-language-runtime/source/browse/#svn/trunk/invokedynamic-backport
run ant to create the jsr292-backport.jar, it has a dependency encoded
in the jar
on asm3.2-all.jar
And run your example (with java5 or java6) :
java -javaagent:lib/jsr292-backport.jar ...
Rémi
More information about the mlvm-dev
mailing list