lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


For a recent paper that I recently worked on, I created a modified
version of Lua 5.4 that can compile Lua functions into C. On some
number-crunchy benchmarks, it managed to get a speedup of 2x compared
to regular Lua 5.4.

It is still full of bugs, and I won't keep it updated with future Lua
versions, so it probably wouldn't be a good idea to use it for anything
serious. That said, I think that it might be scientifically interesting
for some people, so I'm sharing it here :)

https://github.com/hugomg/lua-aot-5.4

The basic idea of how it works is that each bytecode instruction is
converted to a block of C code, which is nearly identical to the C code
used by the regular Lua interpreter. The main difference is that Lua
jumps become C gotos, and that it doesn't decode or dispatch the VM
instructions at run-time, because those become compile-time constants.

For me, the most interesting takeaway is that it can give a rough
measurement of how much of the running time of a regular Lua program is
due to interpreter overhead. That is, how much time is spent decoding
and dispatching VM instructions.

-- Hugo