lua-users home
lua-l archive

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


One of the things that has tripped me up in the past is that there is
an implicit assumption that a Lua value's type code will fit into a
byte. While this is not a limitation of TValue it seems to be the
effect of how the type tag (ttuv_) is stored in Udata struct.

I cannot remember if there are other places where this assumption is
made. In any case it might be worth documenting this assumption.

I was reminded about this as I have been thinking about ways to make
the calls to math functions cheap - by bypassing the normal Lua
calling conventions. One approach I thought of is to have specialized
function type code for C functions that take a double parameter and
return a double.  This could be used by the VM to directly call the C
function.

This would significantly improve the performance of JITed code in Ravi
that needs to call maths functions in a loop. Right now the overhead
is such that performance is degraded in such scenarios.

I understand that LuaJIT automatically optimises calls to math
functions; not sure how it detects such calls though.

Regards
Dibyendu