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.

388 questions
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

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
  • 63,082
  • 19
  • 144
  • 230
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…
vyom
  • 1,244
  • 13
  • 36
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
  • 1
  • 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
1 answer

LuaJIT require module error

require "utils.lua" stdin:1: module 'utils.lua' not found: no field package.preload['utils.lua'] no file 'D:\blizzard\Projects\Lua' no file '.\utils\lua.dll' no file 'D:\blizzard\Projects\Lua\utils\lua.dll' no…
DSblizzard
  • 3,577
  • 7
  • 41
  • 74
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,355
  • 3
  • 28
  • 41
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
  • 8
6
votes
2 answers

NGINX rate limitting by decoded values from JWT token

I have a question regarding NGINX rate limiting. Is it possible to do rate limiting based on the decoded value of JWT token? I cannot find any information like this in the docs. Or even if there is a way of doing rate limiting by creating pure…
Marcin Majewski
  • 865
  • 1
  • 12
  • 26
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 =…
iRyanBell
  • 3,127
  • 6
  • 41
  • 69
6
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
  • 6,518
  • 4
  • 41
  • 91
6
votes
1 answer

How can I list modules and check functions exist at the command line?

Like many "(windows) users" I do not want to spend time learning to compile anything from source. So Lua seems a very good choice for a hobbyist. Sorry if this is a very simple problem - but... Q1. How can I list the modules available to any given…
Gavin
  • 459
  • 4
  • 15
6
votes
1 answer

How to pass a pointer to LuaJIT ffi to be used as out argument?

Assuming there is following C code: struct Foo { int dummy; } int tryToAllocateFoo(Foo ** dest); ...How to do following in LuaJIT? Foo * pFoo = NULL; tryToAllocateFoo(&pFoo);
Alexander Gladysh
  • 34,198
  • 31
  • 94
  • 153
6
votes
1 answer

luajit2.0.0 -- Segmentation fault: 11

I use a simple example from http://lua-users.org/wiki/SimpleLuaApiExample to make a test. The sample can be statically linked with libluajit.a with a success, but this error message occurs when you run it: Segmentation fault: 11 I use LuaJIT-2.0.0…
douyw
  • 3,806
  • 1
  • 25
  • 28
5
votes
3 answers

Would my DSL for Lua work...? (this seems too simply to be true)

I really love Lua as a programming language BUT, it bugs me unbelievably to have to constantly type "local" for all my local variables. It just makes my code look more cluttered. So I am wondering, can I create a Domain Specific Language (DSL) on…
nickb
  • 8,430
  • 11
  • 34
  • 46
1
2
3
25 26