lua-users home
lua-l archive

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


On 22 February 2015 at 15:23, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> I am trying to understand the purpose of the Protect() macro in lvm.c.
>> Is this used when there is a possibility that the stack may have been
>> reallocated - so the base pointer needs to be refreshed?
>
> Exactly.

Thanks Roberto.
A follow up question:

It seems that the stack can be reallocated if there is a function
call. So then in the following snippet is it okay to just protect the
call to luaV_equalobj()?

    case OP_EQ: {
        TValue *rb = RKB(i);
        TValue *rc = RKC(i);
        Protect(
            if (cast_int(luaV_equalobj(L, rb, rc)) != GETARG_A(i))
                ci->u.l.savedpc++;
            else
                donextjump(ci);
        )
    } break;

Regards
Dibyendu