Re: LuaJit FFI with iOS

  • From: Joe Riedel <joeriedel@xxxxxxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Mon, 24 Jun 2013 13:55:57 -0600

Hi Mike,

Does this mean that on targets that don't support JIT that the C API is faster 
than the FFI?

Thanks,

-- Joe
Sent from my iPhone

On Jun 24, 2013, at 4:34, "Mike Pall" <mike-1306@xxxxxxxxxx> wrote:

Dominik Weinhold wrote:
> At the moment I am looking into getting it to run for an iOS app but I'm
> having trouble with the FFI. From what I know Apple does not allow any
> dynamic library in App-Store Apps. So I was wondering if there is a way to
> use the LuaJit FFI with static libraries so that apple will accept it?

Use a static struct holding function pointers on the C side. Pass
a pointer to that as a lightuserdata to Lua. Declare the same
struct on the Lua side and cast the received lightuserdata to a
pointer (or reference) to it.

[You probably know that Apple doesn't permit JIT-compilation,
which means you only get the fast LuaJIT interpreter. Alas, the
FFI is quite slow when only interpreted. This might be a problem
on iOS, if you plan to call C functions via the FFI in performance
sensitive contexts (millions of calls in a loop).]

--Mike


Other related posts: