lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Mike wrote:
> LuaJIT may support loading of its own bytecode format, whenever
> all of these points are fulfilled:
> - The bytecode format is somewhat stable
> - and I find a good external bytecode representation
> - and either I get bored and will do it on my own (unlikely)
> - or someone sponsors the development of bytecode saving/loading.

Started peeking in LuaJIT code. I wonder if there are any caveats in thinking that GCproto serialization/deserialization is sufficient to mimic "luac" compilation - dumping BC, constants and variable info into binary file with some own LuaJIT signature, i.e. "\033LJ2".

Seems to me that GCproto is pretty self-contained having all necessary information about script. What's not clear to me is how to encode constants, especially whether they are just simple types, or tables too.

> Wrt. the representation: I was thinking about generating binary
> object files (.o or .obj). Then you could just link them
> statically or put them into a shared library with no fuss. From
> the outside it would look like a C module with a luaopen_*
> function -- no special logic needed for require().

Altogether that would be best solution, so each object file would contain .text section with single function and .data section with bytecode representation, but that is much more advanced task than just remaking "luac" for LuaJIT :)

Regards,
-- 
Adam Strzelecki