2
0
Эх сурвалжийг харах

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)

Roberto Ierusalimschy 9 жил өмнө
parent
commit
8004ab756f
1 өөрчлөгдсөн 8 нэмэгдсэн , 8 устгасан
  1. 8 8
      lvm.c

+ 8 - 8
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
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -773,10 +773,8 @@ void luaV_execute (lua_State *L) {
   for (;;) {
   for (;;) {
     Instruction i = *(ci->u.l.savedpc++);
     Instruction i = *(ci->u.l.savedpc++);
     StkId ra;
     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));
       Protect(luaG_traceexec(L));
-    }
     /* WARNING: several calls may realloc the stack and invalidate 'ra' */
     /* WARNING: several calls may realloc the stack and invalidate 'ra' */
     ra = RA(i);
     ra = RA(i);
     lua_assert(base == ci->u.l.base);
     lua_assert(base == ci->u.l.base);
@@ -1109,8 +1107,9 @@ void luaV_execute (lua_State *L) {
         int nresults = GETARG_C(i) - 1;
         int nresults = GETARG_C(i) - 1;
         if (b != 0) L->top = ra+b;  /* else previous instruction set top */
         if (b != 0) L->top = ra+b;  /* else previous instruction set top */
         if (luaD_precall(L, ra, nresults)) {  /* C function? */
         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 */
         else {  /* Lua function */
           ci = L->ci;
           ci = L->ci;
@@ -1123,8 +1122,9 @@ void luaV_execute (lua_State *L) {
         int b = GETARG_B(i);
         int b = GETARG_B(i);
         if (b != 0) L->top = ra+b;  /* else previous instruction set top */
         if (b != 0) L->top = ra+b;  /* else previous instruction set top */
         lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
         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 {
         else {
           /* tail call: put called frame (n) in place of caller one (o) */
           /* tail call: put called frame (n) in place of caller one (o) */
           CallInfo *nci = L->ci;  /* called frame */
           CallInfo *nci = L->ci;  /* called frame */