[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT FFI vs Lua binding vs Lua interface
- From: James McKaskill <james@...>
- Date: Mon, 25 Jun 2012 09:44:25 -0400
On Mon, Jun 25, 2012 at 7:50 AM, Thomas Fletcher
<thomas@cranksoftware.com> wrote:
> Not to hijack this thread, but since James is discussing some of the
> internals I thought it might be interesting to understand why he didn't
> re-use the work from a project like libffi?
>
> Was it purely to be LuaJIT compatible or were there other factors?
Couple of reasons:
- The main chunk of work was actually the C parser, which has bits
which are non-standard (e.g. the VLA syntax: struct foo[?]).
- Due to the above I basically needed a full symbol table with all the
size info etc
- For structs and data manip, it's then more work to use libffi as you
already had to have all the size, offset, type info, etc.
- For calls and callbacks: I suppose I could use libffi, but it was
actually really easy to JIT the code using dynasm that I just went
that route. I think I briefly looked at libffi, but it would have been
a hassle to convert all the local type info to libffi and then calls
would still be interpreted. Long term with a bit of inlining the
JITing should produce code not too dissimilar from compiled C using
the lua API.
TLDR: LuaJIT compatibility and then keeping things simple
-- James