lua-users home
lua-l archive

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


Thanks Roberto... and so you need to pass a reference to the register where to store the result of the function or what?
--
Marco Bambini
http://www.sqlabs.com
http://twitter.com/sqlabs
http://instagram.com/sqlabs



> On 14 Jan 2015, at 19:34, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> 
>> In a stack based VM (and I think in the pre 5.x lua version) an
>> efficient way to pass parameters between function calls is via frame
>> overlapping.
>> Since Lua 5 is register based I think that this method cannot be used,
>> so how Lua pass parameters? And how a return value can be stored in
>> the right caller register?
> 
> It uses the same method. You store the arguments in a sequence of free
> registers (such that no higher register is being used) and call the
> function; those registers with the arguments become the first registers
> of the called function.  (Real CPUs can do that too, using register
> windows [1].)
> 
> [1] http://en.wikipedia.org/wiki/Register_window
> 
> -- Roberto
>