lua-users home
lua-l archive

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


On 6 August 2015 at 22:55, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> It is not only L->top that has a dual purpose; the stack has a dual
> usage, due to the way that Lua uses a register-based VM. While inside
> a Lua function, Lua preallocates in the stack all "registers" that the
> function will eventually need. So, while running VM instructions in
> one function, L->top points to the end of its activation record (stack
> frame). When Lua enters or re-enters a Lua function, L->top must be
> corrected to this frame, except when multiple returns are involved.
> In that case, it is true that L->top is used to pass information
> strictly between two consecutive VM instructions. (From either
> OP_CALL/OP_VARARG to one of OP_CALL/OP_RETURN/OP_SETLIST.)
>

Would it be possible to point me to small test snippets of code that
exercise each of these scenarios? I would like to step through those
to see how this works in practice.

Thanks and Regards
Dibyendu