From 8004ab756fe2c9fa5da79da6d17f8e11ab7dea26 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 22 Oct 2015 12:40:47 -0200 Subject: hook test in 'luaV_execute' reduced to minimum (rest done in 'luaG_traceexec'; no difference in performance for the non-hook case, but keeps 'luaV_execute' a little simpler) + 'base' updates replaced by 'Protect' (which serves this rule) --- lvm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lvm.c b/lvm.c index e5ae82b8..98129b24 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.254 2015/10/20 17:41:35 roberto Exp roberto $ +** $Id: lvm.c,v 2.255 2015/10/20 17:56:21 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -773,10 +773,8 @@ void luaV_execute (lua_State *L) { for (;;) { Instruction i = *(ci->u.l.savedpc++); StkId ra; - if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && - (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { + if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) Protect(luaG_traceexec(L)); - } /* WARNING: several calls may realloc the stack and invalidate 'ra' */ ra = RA(i); lua_assert(base == ci->u.l.base); @@ -1109,8 +1107,9 @@ void luaV_execute (lua_State *L) { int nresults = GETARG_C(i) - 1; if (b != 0) L->top = ra+b; /* else previous instruction set top */ if (luaD_precall(L, ra, nresults)) { /* C function? */ - if (nresults >= 0) L->top = ci->top; /* adjust results */ - base = ci->u.l.base; + if (nresults >= 0) + L->top = ci->top; /* adjust results */ + Protect(); /* update 'base' */ } else { /* Lua function */ ci = L->ci; @@ -1123,8 +1122,9 @@ void luaV_execute (lua_State *L) { int b = GETARG_B(i); if (b != 0) L->top = ra+b; /* else previous instruction set top */ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); - if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ - base = ci->u.l.base; + if (luaD_precall(L, ra, LUA_MULTRET)) { /* C function? */ + Protect(); /* update 'base' */ + } else { /* tail call: put called frame (n) in place of caller one (o) */ CallInfo *nci = L->ci; /* called frame */ -- cgit v1.2.3-55-g6feb