Re: LuaJit FFI with iOS

  • From: Mike Pall <mike-1306@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 24 Jun 2013 22:26:19 +0200

Joe Riedel wrote:
> Does this mean that on targets that don't support JIT that the
> C API is faster than the FFI?

Yes, in many cases. Depends on the number and types of arguments
and results.

E.g. lua_tonumber() (Classic Lua/C API) is rather cheap. Whereas
lj_cconv_ct_tv() (interpreted FFI) is costly and nested within
another costly function that handles the calling conventions.

[The equivalent for JIT-compiled FFI would be zero-cost, because
the compiler arranges for the number to be in the right argument
register.]

OTOH userdata type checks with lookups in the registry etc. are
probably more expensive than FFI type checks.

[Those are more or less zero-cost when compiled, too.]

--Mike

Other related posts: