Search code examples
luainlineluajitinlining

Can you explicitly ask the Lua compiler to inline? What about the LuaJIT?


Is there a keyword or some other functionality in the standard Lua compiler that allows you to explicitly inline? What about the LuaJIT?


Solution

  • There is no function inlining in vanilla Lua interpreter. Some tools exist to inline the code on a source level, but that's not what you're asking.

    LuaJIT does some inlining while generating the native code, but that can't be controlled from outside, there's no explicit 'inline' keyword. And there's limits on what could be inlined. I.e. the call to native code using FFI library will be inlined, but the calls to functions registered via classic Lua/C interface can't be.