[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua novice requesting LuaJIT help
- From: Radu Moraru <morarur@...>
- Date: Wed, 20 Apr 2011 00:40:06 +0300
Hello everybody.
I am a Lua novice with exactly 4 days of experience in all things Lua. I am attempting to integrate LuaJIT in a Visual C++ project that already has Lua 5.1 integrated. More specifically, the project has Lua 5.1.1, thus I have selected LuaJIT-1.1.2 since it is based off that particular version.
My efforts have been partially successful. With LuaJIT embedded ( or so I think ) the scripts are indeed processed, but at no performance gain.
The steps I took for installing LuaJIT 1.1.2, after removing any and all references to the Lua 5.1.1 library , are the following :
1) Used luavs.bat to build the luajit.exe and associated dll,lib files. ( Did not modify luaconf.h )
2) As per instructions, created a new folder in the LuaJIT-1.1.2 folder, I named it "lib". Copied lib,dll,exe files to "lib".
3) Created inside "lib" the "lua" folder. Inside "lua" the "jit" folder. Copied contents of "LuaJIT-1.1.2\jit" to "LuaJIT-1.1.2\lib\lua\jit"
4) Referenced the header and lib files as needed throughout the Visual C++ solution, replacing the previous Lua references to Lua 5.1.1 files. ( One of the first things I triple-checked, there are no remaining references or even files belonging to Lua 5.1.1 in the solution or project folder )
The installation instructions caution against usage of certain Lua functions. I have checked the relevant project files, no such problematic functions are used.
The installation instructions also stress the usage of the luaL_openlibs() function as defined in the LuaJIT linit.c. This is automatically achieved by including the relevant header file, lualib.h, right?
There is however an installation step whose instructions elude me, the installation step that is likely the critical one missing. A consequence of me being a novice, I am sure : activating the optimizer.
Copy/pasted from the installation instructions :
---
Install the optimizer modules jit.opt and
jit.opt_inline relative to the Lua module path
(you've probably modified it — see src/luaconf.h):
jit/opt.lua
jit/opt_inline.lua
If you want to ship a single executable then you may want to
embed the optimizer modules into your application (but don't loose
time with this during the early development phase). This involves:
- Compile the two modules to bytecode
(using luac -s from a plain Lua installation).
- Convert them to C include files (search for "Lua bin2c")
- On Windows you can also put the compiled bytecode into a resource
(search for "Lua bin2res").
- Load the bytecode with luaL_loadbuffer (but don't run it).
- Put the resulting functions into package.preload["jit.opt"]
and package.preload["jit.opt_inline"].
Activate the LuaJIT optimizer from Lua code to be run at startup:
require("jit.opt").start()
Or use equivalent C code. See dojitopt() in src/lua.c.
---
With great embarassment I admit the instructions lost me at the first phrase and they do not get clearer as they progress.
Just how would I go about installing these modules ?
What exactly does "Load the bytecode with luaL_loadbuffer (but don't run it)" ?
How exactly does one put the resulting functions into packages ?
At which startup am I supposed to run the "require" ?
Can anybody help me,point me the right way, to the right documentation ? The Lua documentation I have seen deals with what Lua itself can do but little in the way of the finer points of packages and "requires".
I readily admit I may very well be in way over my head, particularly with my very limited knowledge of POSIX systems. When I read install, I look for an exe,msi or bat.
So if anybody can give me a shove to get back on track, I would greatly appreciate it.
Thank you.