An ongoing attempt to re-engineer LuaJIT from scratch
This is a work-in-progress.
The ultimate goal of this project is to implement a multi-tier method-JIT for Lua.
We employ an unique approach where the interpreter and the JIT tiers are automatically generated from a semantical description of the bytecodes. We believe this will ultimately result in less engineering cost, cleaner and more maintainable code, as well as the generalizability to support other languages.
Currently we have implemented:
If you would like to understand more about our design, the following blog posts are a good starting point:
On a variety of benchmarks, we demonstrate that our interpreter is 34.6% faster than LuaJIT's interpreter, and 185% faster than the official PUC Lua5.1 interpreter[^1].
The following figure illustrates our performance vs LuaJIT interpreter, normalized to PUC Lua's performance. Blue shadow indicates benchmarks where we do better than LuaJIT, and red shadow indicates benchmarks where LuaJIT does better than us.
[^1]: The benchmarks are run on my laptop with Intel i7-12700H CPU and 32GB DDR4 memory. All benchmarks are repeated 5 times. Reported numbers are the geometric average over all benchmarks.
The work for implementing the JIT tiers is ongoing...
To build the project, make sure you have docker
and python3
installed, and run:
python3 ljr-build make release
Once the build is complete, you should see an executable luajitr
in the repository root directory. You can use it to run your Lua script, or run bash run_bench.sh
to run all the benchmarks.
Please note that this is an ongoing project that is still far from production-ready.
It currently comes with a number of caveats:
require
and module
), are not implemented.