Last weekend I wrote a JIT for libgcj using libjit.
Well, 90% of a JIT anyway.
libjit is remarkably simple to use. It took me about a day to
write a functioning (if not completely debugged) JIT for java
bytecode. On some microbenchmarks it was between 2 and 6 times faster
than the existing bytecode interpreter.
I’ve checked it in to the old gcjx
repository… but you won’t be able to see it; I heard that
sourceforge has stopped updating its anonymous CVS. Email me if you
want a copy. The repository includes a patch for libgcj, the needed
modifications there are very minor.
Note that exception handling doesn’t work. This is somewhat hard
to do, since it requires modifying the JIT and also (probably)
patching libgcc. And…
Unfortunately libjit is pure GPL, so I doubt we’ll be including
this in libgcj, or even finishing it. Instead I think I’ll
investigate rewriting this JIT using LLVM instead. I’ve been thinking
of generalizing my existing patch to libgcj to make it possible to
dynamically load a JIT. That would make it easier to experiment here.