Questions tagged [luajit]

LuaJIT is a Just-In-Time Compiler for the Lua programming language. LuaJIT offers more performance, at the expense of portability. On the supported OS's (all popular operating systems based on x86 or x64 CPUs (Windows, Mac OSX, Linux, ...), ARM based embedded devices (Android, iOS) and PPC/e500v2 CPUs) it offers an API- and ABI-compatible drop-in replacement for the standard Lua interpreter.

Overview

LuaJIT is a high-performance, Just-In-Time(JIT) implementation by Mike Pall for the Lua programming language. It has been successfully used as a scripting middleware in games, 3D modelers, numerical simulations, trading platforms and many other specialty applications. It combines high flexibility with high performance and an unmatched low memory footprint: less than 125K for the virtual machine(VM) plus less than 85K for the JIT compiler (on x86).

LuaJIT has been in continuous development since 2005. It's widely considered to be one of the fastest dynamic language implementations. It has outperformed other dynamic languages on many cross-language benchmarks since its first release — often by a substantial margin. In 2009 other dynamic language VMs started to catch up with the performance of LuaJIT 1.x. Well, I couldn't let that slide. ;-)

2009 also marks the first release of the long-awaited LuaJIT 2.0. The whole VM has been rewritten from the ground up and relentlessly optimized for performance. It combines a high-speed interpreter, written in assembler, with a state-of-the-art JIT compiler. An innovative trace compiler is integrated with advanced, SSA-based optimizations and a highly tuned code generation backend. This allows a substantial reduction of the overhead associated with dynamic language features.

It's destined to break into the performance range traditionally reserved for offline, static language compilers.

Compatibility

LuaJIT implements the full set of language features defined by Lua 5.1. The virtual machine is API- and ABI-compatible to the standard Lua interpreter and can be deployed as a drop-in replacement.

LuaJIT offers more performance, at the expense of portability. It currently runs on all popular operating systems based on x86 or x64 CPUs (Linux, Windows, OSX etc.) or embedded systems based on ARM (Android, iOS) or PPC/e500v2 CPUs. Other platforms will be supported in the future, based on user demand and sponsoring.

430 questions
8
votes
1 answer

Does LuaJIT support __gc for tables?

Lua 5.2 (in contrast to 5.1) supports __gc for tables. Has LuaJIT borrowed this nice feature? (I did a google search, and examined LuaJIT's Change History but couldn't figure out the answer.)
Niccolo M.
  • 3,363
  • 2
  • 22
  • 39
7
votes
4 answers

LuaJIT not seeing rocks installed by LuaRocks

lua -e "print(package.path)" ./?.lua;/usr/share/lua/5.1/?.lua;/usr/share/lua/5.1/?/init.lua;/usr/lib/lua/5.1/?.lua;/usr/lib/lua/5.1/?/init.lua luajit -e…
7
votes
1 answer

llvm/tools: lli REPL compared to LuaJIT

I was wondering if someone has had experience with the llvm/tools - lli interpreter/JIT-compiler (cf. http://llvm.org/docs/GettingStarted.html#tools). I am interested in any information that you can provide (speed, complexity, implementations,…
are
  • 71
  • 3
7
votes
1 answer

lua_open returns null using luaJIT

Using the recent luaJIT lua_open returns null. This does not happen with the regular lua library. lua_State *L = lua_open(); std::cout << L << std::endl; Output: 0x0 How can I get luaJIT to work? SSCCE: #include #include…
Appleshell
  • 7,088
  • 6
  • 47
  • 96
7
votes
1 answer

How can I detect at runtime if I am running Luajit or PUC Lua 5.1?

I am writing some test scripts for my Lua project and I want to be sure that they run correctly under the different Lua versions available. Since my unit testing framework can use the wrong Lua version if I misconfigure it, I would like to be extra…
hugomg
  • 68,213
  • 24
  • 160
  • 246
7
votes
1 answer

Embedding LuaJIT module into C application

In my application, I have all the Lua libraries exposed from the C backend. Now, I have a need to load a Lua module. The method for this seems to be : lua_getglobal(L, "require"); lua_pushstring(L, libname); lua_pcall(L, 1, 0, 0); which will search…
Ani
  • 1,448
  • 1
  • 16
  • 38
7
votes
2 answers

When using Luajit, is it better to use FFI or normal lua bindings?

I just started tinkering with Luajit with C++ and I see that it's FFI is really easy to use but I am not sure if it is the best solution for all (or at least most) cases. So is it better to use one or the other, or is it just preference?
benbot
  • 1,217
  • 1
  • 12
  • 28
7
votes
4 answers

LuaJIT FFI callback performance

The LuaJIT FFI docs mention that calling from C back into Lua code is relatively slow and recommend avoiding it where possible: Do not use callbacks for performance-sensitive work: e.g. consider a numerical integration routine which takes a…
Miles
  • 31,360
  • 7
  • 64
  • 74
6
votes
2 answers

Differences between standard Lua bytecode and LuaJIT bytecode

I've been trying to decompile a LuaJIT bytecode file. I have managed to disassemble it (but can't find any way to reassemble it). So I am considering writing some software to convert from LuaJIT bytecode to standard Lua bytecode that would then run…
R4000
  • 113
  • 2
  • 7
6
votes
3 answers

Passing C struct pointer to lua script

I would like to know is there a way to pass a struct pointer to a lua script, and reach it's members from lua without copy (for read and write purposes). So, for example is it possible to overwrite a member of a c struct directly through of its…
user408141
6
votes
2 answers

LuaJIT and Rocks?

Just a small question from a "Lua newbie"...I have been using LuaJIT and it is awesome, no the question is since LuaJIT is Lua 5.1 compatible does that mean I can use all the "LuaRocks" that standard Lua uses in LuaJIT? For instance if I wanted to…
Lynton Grice
  • 1,435
  • 3
  • 29
  • 45
6
votes
2 answers

Modifying a C++ array in main() from Lua without extra allocation

I am sketching a small C++ program that will pass arrays to Lua and have them modified there, where I intend to have a lua script read in the program so I can modify it without needing to recompile the program My first obstacle is to ensure Lua is…
JayY
  • 109
  • 10
6
votes
1 answer

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

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…
user6245072
  • 2,051
  • 21
  • 34
6
votes
1 answer

What is "loadall.so"?

Looking at the default Lua cpath with luajit: luajit -e "print(package.cpath)" I get: ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so What is the purpose of the loadall.so? It doesn't actually…
timbo
  • 13,244
  • 8
  • 51
  • 71
6
votes
3 answers

Luasocket + nginx error - lua entry thread aborted: runtime error: attempt to yield across C-call boundary

When I use the following script: local smtp = require("socket.smtp") local from = "from@host" local rcpt = "rcpt@host" local msg = { headers = { to = rcpt, subject = "Hi" }, body = "Hello" } smtp.send{from = from,rcpt = rcpt,source =…
user479947
1
2
3
28 29