diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 19 |
1 files changed, 5 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.189 2018/01/29 16:21:35 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.190 2018/02/06 19:16:56 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -297,15 +297,11 @@ void luaD_hook (lua_State *L, int event, int line) { | |||
297 | /* | 297 | /* |
298 | ** Executes a call hook for Lua functions. This function is called | 298 | ** Executes a call hook for Lua functions. This function is called |
299 | ** whenever 'hookmask' is not zero, so it checks whether call hooks are | 299 | ** whenever 'hookmask' is not zero, so it checks whether call hooks are |
300 | ** active. Also, this function can be called when resuming a function, | 300 | ** active. |
301 | ** so it checks whether the function is in its first instruction. | ||
302 | */ | 301 | */ |
303 | void luaD_hookcall (lua_State *L, CallInfo *ci) { | 302 | void luaD_hookcall (lua_State *L, CallInfo *ci) { |
304 | Proto *p = clLvalue(s2v(ci->func))->p; | ||
305 | int hook = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL : LUA_HOOKCALL; | 303 | int hook = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL : LUA_HOOKCALL; |
306 | ci->u.l.trap = 1; /* there may be other hooks */ | 304 | if (!(L->hookmask & LUA_MASKCALL)) /* some other hook? */ |
307 | if (!(L->hookmask & LUA_MASKCALL) || /* some other hook? */ | ||
308 | ci->u.l.savedpc != p->code) /* not 1st instruction? */ | ||
309 | return; /* don't call hook */ | 305 | return; /* don't call hook */ |
310 | L->top = ci->top; /* prepare top */ | 306 | L->top = ci->top; /* prepare top */ |
311 | ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ | 307 | ci->u.l.savedpc++; /* hooks assume 'pc' is already incremented */ |
@@ -417,7 +413,7 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { | |||
417 | int i; | 413 | int i; |
418 | for (i = 0; i < narg1; i++) /* move down function and arguments */ | 414 | for (i = 0; i < narg1; i++) /* move down function and arguments */ |
419 | setobjs2s(L, ci->func + i, func + i); | 415 | setobjs2s(L, ci->func + i, func + i); |
420 | checkstackp(L, fsize, func); | 416 | luaD_checkstackaux(L, fsize, (void)0, luaC_checkGC(L)); |
421 | func = ci->func; /* moved-down function */ | 417 | func = ci->func; /* moved-down function */ |
422 | for (; narg1 <= nfixparams; narg1++) | 418 | for (; narg1 <= nfixparams; narg1++) |
423 | setnilvalue(s2v(func + narg1)); /* complete missing arguments */ | 419 | setnilvalue(s2v(func + narg1)); /* complete missing arguments */ |
@@ -425,10 +421,7 @@ void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int narg1) { | |||
425 | lua_assert(ci->top <= L->stack_last); | 421 | lua_assert(ci->top <= L->stack_last); |
426 | ci->u.l.savedpc = p->code; /* starting point */ | 422 | ci->u.l.savedpc = p->code; /* starting point */ |
427 | ci->callstatus |= CIST_TAIL; | 423 | ci->callstatus |= CIST_TAIL; |
428 | if (p->is_vararg) { | 424 | L->top = func + narg1; /* set top */ |
429 | L->top = func + narg1; /* set top */ | ||
430 | luaT_adjustvarargs(L, nfixparams, narg1 - 1); | ||
431 | } | ||
432 | } | 425 | } |
433 | 426 | ||
434 | 427 | ||
@@ -481,8 +474,6 @@ void luaD_call (lua_State *L, StkId func, int nresults) { | |||
481 | lua_assert(ci->top <= L->stack_last); | 474 | lua_assert(ci->top <= L->stack_last); |
482 | ci->u.l.savedpc = p->code; /* starting point */ | 475 | ci->u.l.savedpc = p->code; /* starting point */ |
483 | ci->callstatus = 0; | 476 | ci->callstatus = 0; |
484 | if (p->is_vararg) | ||
485 | luaT_adjustvarargs(L, nfixparams, narg); /* may invoke GC */ | ||
486 | luaV_execute(L, ci); /* run the function */ | 477 | luaV_execute(L, ci); /* run the function */ |
487 | break; | 478 | break; |
488 | } | 479 | } |