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
0
votes
1 answer

How to download a dataset to arbitrary location in Torch?

How can I download a dataset to arbitrary location. For example: require "dp" local datasource = dp.BillionWords{context_size=5, train_file="train_tiny.th7"} Attempts to download the dataset into ~/ while I need it to be downloaded to…
minerals
  • 6,090
  • 17
  • 62
  • 107
0
votes
1 answer

Applying quantifier to a sentence in Lua pattern

So I am trying to parse out #define statements out of a C file using Lua patterns, but there is the case on multiline defines, where you might escape the newline character with a backslash. In order for me to know where the define ends, I need to be…
Luiz Berti
  • 1,421
  • 1
  • 15
  • 24
0
votes
1 answer

Strange output for luajit ffi function returning string

I have a function like the following returning a c-string from an another function returning a std::string. const char* GetFilePath(const char* aFilename) { return FileSystem->GetFilePath(aFilename).c_str(); } If I call this function from lua I…
char8_t
  • 320
  • 2
  • 8
0
votes
1 answer

Why does Lua/Torch run out of memory when an `self` is returned to console from a `torch.class` method?

I've modified the torch-dataframe to return self instead of void in order to achieve simple method chaining for a torch.class. Unfortunately this seems to be causing havoc with memory issues: th> require 'Dataframe'; df =…
Max Gordon
  • 5,367
  • 2
  • 44
  • 70
0
votes
0 answers

How to display RGB image in zerobrane studio?

On Ubuntu 14.04, if I run the following code within the qlua interpreter invoked via the command line (with or without the first line), it displays the Lena image : require('mobdebug').start() -- for image.display() require…
DJensen
  • 1
  • 2
0
votes
1 answer

Use struct names in LuaJIT FFI error messages

When I do something wrong in LuaJIT FFI, I can get an error message like "Cannot convert struct 129 to struct 141". How can I understand which structs are meant? In my code, all C structs have a typedef, which FFI of course knows about, since it can…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
0
votes
1 answer

C library build for LuaJit

Please, help me to understand the build process for luajit. If I want to compile a c library I use this code: gcc -shared -fpic -O -I/path-to-luajit-headers/luajit-2.1 mylib.c -o mylib.so Is it needed to use more specific parameters like this: gcc…
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
0
votes
1 answer

How to use shared_ptr in LuaJIT FFI/C++ binding?

I am working on creating a Lua binding to another C++ project. After some investigation, LuaJIT FFI seems to be the best choice to achieve that goal. I really benefit from the lua-user mail list archive [1] and another related slide [2]. Actually a…
Xuan Hu
  • 856
  • 8
  • 22
0
votes
1 answer

How to use Lua FFI with C++ functions

I have followed this tutorial to create an FFI interface to some C code to torch However, it doesn't work for C++ functions. Is it even possible, if so how? I created a shared library from the C++ file (simple.cpp) like so: g++ -Wall -shared -fPIC…
StarLord
  • 1,012
  • 1
  • 11
  • 22
0
votes
1 answer

Unexpected behavior at torch7

I was working on generating an XOR gate dataset with torch7. But when i printed the dataset i saw that the data was wrong, but i could not find the bug. There seems to be nothing wrong with the code. But I'm new to torch, so mistakes can happen. So,…
Shubhashis
  • 10,411
  • 11
  • 33
  • 48
0
votes
1 answer

Kong: Luajit not found

I'm trying to get kong working, but every time I run kong start I get a /usr/local/bin/kong: 3: exec: /usr/local/bin/luajit: not found, which is weird as I do have luajit installed? My /usr/local/bin contains these files: forever kong lua2json …
Mobilpadde
  • 1,871
  • 3
  • 22
  • 29
0
votes
0 answers

LuaJIT FFI crashes when freeing memory

I create a cdata object: session = ffi.new("GAMESession*[1]", {}) I pass it in my C++ function: GAMEDLL.GAME_close(session[0]) That C++ function has this code: GAMEErrorCode GAME_close(GAMESession *match) { if (!match) { return…
theman
  • 345
  • 1
  • 14
0
votes
1 answer

lua ffi functions sharing namespace

I'm able to share the same "namespace" for two different libraries using LuaJit in Linux A = ffi.load(ffi.os == "Windows" and "opengl32" or "GLESv2") B = ffi.load(ffi.os == "Windows" and "glfw3" or "glfw") C = B,A Doing this allows me to call…
Chris Camacho
  • 1,164
  • 1
  • 9
  • 31
0
votes
0 answers

link luajit bytecode as dynamic library

I have: --main.lua print("Hello from main.lua") //main.c #include #include "lua.h" #include "lauxlib.h" #include "lualib.h" int main(int argc, char **argv) { int status; lua_State *L = luaL_newstate(); luaL_openlibs(L); …
nonchip
  • 1,084
  • 1
  • 18
  • 36
0
votes
1 answer

Unable to find Torch header files using nvcc

I'm trying to call some CUDA code from luaJIT (Torch) but I'm running into compiling issues. nvcc seems unable to find my Torch header files. I have CUDA 6.5 and gcc 4.4.7. nvcc -o im2col -I/deep/u/ibello/torch/include im2col.cu In file included…
user3431929
  • 23
  • 1
  • 6