Home
About
LuaCLR is a new compiler for the Lua language that targets the CLR. It compiles from source, and will support the full Lua 5.1 language (apart from the C API, naturally). LuaCLR is being developed by Fabio Mascarenhas.
Why LuaCLR
A few years ago (late 2003/early-mid 2004) I wrote Lua2IL as part of my MsC thesis. Lua2IL compiled (or I prefer to say translated) bytecodes from the Lua 5.0 VM to CLR bytecodes, or IL instructions. It was a full implementation of the Lua language, though most of the Lua standard library was missing, and coroutines were much more inefficient, as I had to use threads to simulate them.
As Lua2IL did a straightforward translation of the Lua bytecodes, the runtime system copied several parts of Lua’s runtime system, specially the arguments/locals/temporaries stack, passed from Lua function to Lua function. This meant that Lua locals were not CLR locals, and Lua arguments were not CLR arguments. But the control stack was CLR’s, and the generated code was pretty fast, faster than similar languages for the CLR, at the time.
But I wasn’t satisfied, I wanted to eventually do a full reimplementation of Lua for the CLR, including the lexer and parser. Working directly from source would make optimizing the code easier then working from bytecodes, and I hoped to improve the performance significantly. I also wanted to cut the dependency on the Lua VM compiler, so Lua on the CLR could stand on its own. Late 2006 I finally started working on it, and a few months later LuaCLR was born.
Since then the compiler has progressed a lot, and I revised several of my initial assumptions (some of which were invalidated by the evolution of the CLR). Benchmarks show the compiler to already utperform the Lua interpreter for common operations, and my goal is to get as close to LuaJIT as possible.