lua-users home
lua-l archive

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


2011/4/14 Adam Strzelecki <ono@java.pl>:
> Correct me if I am wrong, but I think FFI really improves performance, since it can optimally couple internal Lua variable representation with function call rather than doing regular parameters/stack packing known from C wrapper modules which means extra utility function calls.
>
> For example calling C "double cos(double x)" with FFI should have same performance as calling it in C language using native types, since anyway LuaJIT uses doubles internally, so it can pass the parameters without almost no checking, no type conversion. At least this is what I expect and believe :)

Yep! As far as I understood this is actually the case, LuaJIT is able
to optimize FFI calls to the equivalent of compiled C code. For the
other side Mike exmplained that calling a Lua C function from Lua will
always have an important overhead that LuaJIT cannot eliminate. This
is why he was suggesting to use LuaJIT plus FFI calls instead of
writing Lua C functions.

Francesco