What's the difference in the way Lua and LuaJIT process the code?
Asked Answered
A

1

7

From what I understood, the standard Lua interpreter first compiles the input code to "bytecode" (the output of luac) and then "interpretes" that bytecode.

But isn't that basically the definition of a JIT compiler? What does LuaJIT do then? How does it differ from the standard Lua interpreter? How can it be this faster?

Argentum answered 2/3, 2017 at 22:15 Comment(0)
K
5

isn't that basically the definition of a JIT compiler? What does LuaJIT do then?

It implements its own interpreter, which is often faster than the "standard" Lua interpreter and it JIT-compiles frequently visited fragments to machine instructions, which brings further performance gains, but limits the portability (as those instructions are machine/architecture-specific).

There are many more improvements and optimizations, which you can find in Mike Pall's overview. Also see this page for the overall JIT discussion and specifically Mike Pall's comments on it.

Krug answered 2/3, 2017 at 22:34 Comment(2)
What interpreter does Lua use?Argentum
@Argentum - Vanilla Lua uses "PUC Lua interpreter" (it is not fast, but portable)Bethina

© 2022 - 2024 — McMap. All rights reserved.