luje

a pure Lua JVM

What is it?

luje is an experimental (read: toy) Java virtual machine written in pure Lua.
It works by compiling Java bytecode into Lua scripts on-the-fly and then
running them using Mike Pall's LuaJIT 2. The
result is an extremely fast but incredibly lightweight Java virtual machine
which can outperform the server JIT used in OpenJDK in some situations.

Right now it excels at anything which involves tight loops and float or doubles
in local variables --- see the LocalBench benchmark. It'll comfortably beat
Hotspot (on amd64, or Zero on ARM) with those. However, it's not good at longs
(although much better than it used to be). stored in hash tables, so accessing
fields in an inner loop will tend to cause luje to slow down. It hasn't really
had any testing with non-trivial benchmarks yet; if anyone has any
recommendations, please email me. Still, given that the whole thing is less
than 3000 lines of code the performance so far is damn good.

Consider these two carefully chosen unrepresentative microbenchmarks.
LocalBench (lib/com/cowlark/luje/LocalBench.java in the
distribution) performs some simple computations on local variables. FieldBench
(lib/com/cowlark/luje/FieldBench.java) performs the same
computations, but the values are stored in fields and the computation is done
via a method call.

There's plenty more optimisation that can be done --- laying out data
structures in a way that's more friendly to the JIT would be good --- but it's
already looking extremely promising. The memory footprint is a tiny fraction
the size of IcedTea, too.

Currently it's in an extremely unfinished and fragile state. Not all bytecodes
are implemented (including the rather important wide), and the
runtime library (stolen from Apache Harmony) has a number of things stubbed
out. There are many bugs. It's certainly not useful for real work yet, and may
not be at ever. See the bug tracker for
details.

How do I use it?

Download it, build the Java side of things with ant, and then run it with the
supplied shell script. (As it's all just a small pile of Lua scripts, it
doesn't need compiling itself.) Full instructions are in the README.

Who wrote it?

I, David Given, wrote it. Got any comments,
criticism, cake? Send it to dg@cowlark.com.
If there's interest, I'll set up a mailing list.

What's the license?

luje is distributable under the terms of the Simplified
BSD License. It also contains code derived from the Apache Harmony project,
which is available under the Apache 2.0 license.