[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Notes on 5.2 Bytecode and Virtual Machine
- From: "Pierre Chapuis" <catwell@...>
- Date: Mon, 25 Feb 2013 16:59:53 +0100
>> https://github.com/dlaurie/lua52vm-tools/blob/master/zip/lua52bytecode_and_vm-0.1.zip
>
> Very nice. If there is any interest, I can update my bytecode inspector
> library lbci to Lua 5.2: http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lbci
If anybody is interested, I have written an Lua 5.2 bytecode parser in
LuaJIT [1] some time ago.
It can be used to inspect bytecode like luac:
[lualua 16:52] cat hello.lua
local hello = "Hello"
print (hello.." World!")
[lualua 16:53] luac -o hello.luac hello.lua
[lualua 16:53] luajit dumpbc.lua hello.luac
main <hello.lua:0,0> (7 instructions)
0+ param, 4 slots, 1 upvalue, 1 local, 3 constants, 0 function
1 [1] LOADK 0 -1
2 [2] GETTABUP 1 0 -2
3 [2] MOVE 2 0
4 [2] LOADK 3 -3
5 [2] CONCAT 2 2 3
6 [2] CALL 1 2 1
7 [2] RETURN 0 1
constants (3):
1 Hello
2 print
3 World!
locals (1):
1 hello 2 8
upvalues (1):
1 _ENV 1 0
But of course the main interest is to use it as a library to do your own
things with the bytecode.
I actually intended to implement a working Lua 5.2 VM in LuaJIT at the
time but I got lazy (and distracted by more urgent things), so only the
bytecode parser works...
[1] https://github.com/catwell/lualua
--
Pierre Chapuis