[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Parameter passing in a register based VM
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 14 Jan 2015 16:34:20 -0200
> 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