lua-users home
lua-l archive

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


On 14 March 2015 at 15:03, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> The 'top' field in CallInfo. Is this always 'base' +
>> 'Proto.maxstacksize'  ? Is this fixed at the time of the function
>> entry or can the 'top' change during execution?
>
> Of course it changes every time the function calls another function,
> so every return to the function must set 'top' again (see your last
> message). The only exception to this rule is for undefined multiple
> returns (an "open call"), like in '{f()}'. In that case, OP_CALL leaves
> 'top' unchanged to indicate how many values were returned, and the next
> instruction, 'OP_SETLIST', uses it and then corrects it.

I understand that L->top changes across function calls, but can
ci->top for a given frame also change?

>
>> The 'maxstacksize' in Proto - is this fixed when the function is
>> compiled or can it change over time? What does it take into account?
>
> You can find that out for yourself, can't you? 'grep maxstacksize l*.c'
> shows you all (four) locations where this value is assigned.
>

Yes I did that but am not sure I fully understand what it represents.
I thought that 'maxstacksize' reflects however many registers the
function might ever need - and that includes any temporaries it needs
during execution.  But it doesn't seem to be exactly that ... from
what I can figure when the function executes the L->top could be
beyond ci->top.

Is it that 'maxstacksize' represents the number of registers that must
be left on the current stack frame when a new stack frame is pushed?