diff --git a/ldebug.c b/ldebug.c index a3a536bb..9e341f11 100644 --- a/ldebug.c +++ b/ldebug.c @@ -364,11 +364,11 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, break; } case 'r': { - if (ci == NULL || !(ci->callstatus & CIST_TRAN)) + if (ci == NULL || !(ci->callstatus & CIST_HOOKED)) ar->ftransfer = ar->ntransfer = 0; else { - ar->ftransfer = ci->u2.transferinfo.ftransfer; - ar->ntransfer = ci->u2.transferinfo.ntransfer; + ar->ftransfer = L->transferinfo.ftransfer; + ar->ntransfer = L->transferinfo.ntransfer; } break; } diff --git a/ldo.c b/ldo.c index 1d1b7a71..d63c8267 100644 --- a/ldo.c +++ b/ldo.c @@ -357,7 +357,6 @@ void luaD_hook (lua_State *L, int event, int line, int ftransfer, int ntransfer) { lua_Hook hook = L->hook; if (hook && L->allowhook) { /* make sure there is a hook */ - unsigned mask = CIST_HOOKED; CallInfo *ci = L->ci; ptrdiff_t top = savestack(L, L->top.p); /* preserve original 'top' */ ptrdiff_t ci_top = savestack(L, ci->top.p); /* idem for 'ci->top' */ @@ -365,18 +364,15 @@ void luaD_hook (lua_State *L, int event, int line, ar.event = event; ar.currentline = line; ar.i_ci = ci; - if (ntransfer != 0) { - mask |= CIST_TRAN; /* 'ci' has transfer information */ - ci->u2.transferinfo.ftransfer = ftransfer; - ci->u2.transferinfo.ntransfer = ntransfer; - } + L->transferinfo.ftransfer = ftransfer; + L->transferinfo.ntransfer = ntransfer; if (isLua(ci) && L->top.p < ci->top.p) L->top.p = ci->top.p; /* protect entire activation register */ luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ if (ci->top.p < L->top.p + LUA_MINSTACK) ci->top.p = L->top.p + LUA_MINSTACK; L->allowhook = 0; /* cannot call hooks inside a hook */ - ci->callstatus |= mask; + ci->callstatus |= CIST_HOOKED; lua_unlock(L); (*hook)(L, &ar); lua_lock(L); @@ -384,7 +380,7 @@ void luaD_hook (lua_State *L, int event, int line, L->allowhook = 1; ci->top.p = restorestack(L, ci_top); L->top.p = restorestack(L, top); - ci->callstatus &= ~mask; + ci->callstatus &= ~CIST_HOOKED; } } @@ -525,7 +521,7 @@ void luaD_poscall (lua_State *L, CallInfo *ci, int nres) { moveresults(L, ci->func.p, nres, fwanted); /* function cannot be in any of these cases when returning */ lua_assert(!(ci->callstatus & - (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_TRAN | CIST_CLSRET))); + (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_CLSRET))); L->ci = ci->previous; /* back to caller (after closing variables) */ } diff --git a/lstate.h b/lstate.h index aa9687ae..e12ca154 100644 --- a/lstate.h +++ b/lstate.h @@ -183,8 +183,6 @@ typedef struct stringtable { ** yield (from the yield until the next resume); ** - field 'nres' is used only while closing tbc variables when ** returning from a function; -** - field 'transferinfo' is used only during call/returnhooks, -** before the function starts or after it ends. */ struct CallInfo { StkIdRel func; /* function index in the stack */ @@ -206,10 +204,6 @@ struct CallInfo { int funcidx; /* called-function index */ int nyield; /* number of values yielded */ int nres; /* number of values returned */ - struct { /* info about transferred values (for call/return hooks) */ - int ftransfer; /* offset of first value transferred */ - int ntransfer; /* number of values transferred */ - } transferinfo; } u2; l_uint32 callstatus; }; @@ -236,15 +230,13 @@ struct CallInfo { #define CIST_HOOKYIELD (cast(l_uint32, 1) << 14) /* function "called" a finalizer */ #define CIST_FIN (cast(l_uint32, 1) << 15) -/* 'ci' has transfer information */ -#define CIST_TRAN (cast(l_uint32, 1) << 16) /* function is closing tbc variables */ -#define CIST_CLSRET (cast(l_uint32, 1) << 17) -/* Bits 18-20 are used for CIST_RECST (see below) */ -#define CIST_RECST 18 /* the offset, not the mask */ +#define CIST_CLSRET (cast(l_uint32, 1) << 16) +/* Bits 17-19 are used for CIST_RECST (see below) */ +#define CIST_RECST 17 /* the offset, not the mask */ #if defined(LUA_COMPAT_LT_LE) /* using __lt for __le */ -#define CIST_LEQ (cast(l_uint32, 1) << 21) +#define CIST_LEQ (cast(l_uint32, 1) << 20) #endif @@ -354,6 +346,10 @@ struct lua_State { int basehookcount; int hookcount; volatile l_signalT hookmask; + struct { /* info about transferred values (for call/return hooks) */ + int ftransfer; /* offset of first value transferred */ + int ntransfer; /* number of values transferred */ + } transferinfo; };