lua-users home
lua-l archive

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


Hi,

I am looking at an optimization scenario. My goal is to allow certain
native C functions that take one or two primitive arguments and return
a primitive, to be called directly by the VM bypassing the normal Lua
function call sequence. Examples of functions that can be handled this
way are the maths functions.

My plan is to enhance the CClosure structure with an additional field
- that will encode the C function's argument types and the return
type.

I would like to validate my understanding of the Lua stack state when
luaD_precall() is invoked from the VM. I believe that the arguments of
the function are already placed on the Lua stack, and that L->top -
'ra' is the number of arguments. Is that correct?

Also after the called function returns, the return value must be
placed in the 'ra' register (assuming single return value) - is that
correct?

Thanks and Regards
Dibyendu