Building a baseline JIT for Lua automatically (2023)

Deegen is a research meta-compiler that automatically generates high-performance virtual machines (VMs) for dynamic languages. It takes in a semantic description of VM bytecodes in C++ and uses it to generate a high-performance VM at build time. Deegen has been used to generate a JIT-capable VM for Lua 5.1, named LuaJIT Remake, which includes optimizations such as automatic call inline caching, automatic generic inline caching, and hot-cold-splitted JIT code. The baseline JIT in LuaJIT Remake is generated automatically from the same bytecode semantic description, eliminating the need for manual assembly knowledge and engineering. The author explains the background of modern dynamic language VMs, multi-tier JIT compilers, and baseline JITs, as well as the technique of Copy-and-Patch compilation for generating machine code. Copy-and-Patch allows code to be generated without knowing how to generate code, by using relocation records and runtime constants. The author introduces improvements to the Copy-and-Patch technique, such as automatic identification and propagation of runtime constants, as well as fixing the symbol range assumption. The post concludes with an explanation of how Deegen further extends Copy-and-Patch to fully automate the process and fit it for the domain-specific

https://sillycross.github.io/2023/05/12/2023-05-12/

To top