Browse Source

flag CIST_REENTRY changed to CIST_FRESH (its negation); fresh invocations
seem to be less frequent than reentries. (So, avoid setting flag on
the frequent case.)

Roberto Ierusalimschy 9 years ago
parent
commit
07a2dcacbf
2 changed files with 6 additions and 6 deletions
  1. 3 3
      lstate.h
  2. 3 3
      lvm.c

+ 3 - 3
lstate.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lstate.h,v 2.124 2015/09/08 15:41:05 roberto Exp roberto $
+** $Id: lstate.h,v 2.125 2015/09/22 14:18:24 roberto Exp roberto $
 ** Global State
 ** Global State
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -89,8 +89,8 @@ typedef struct CallInfo {
 #define CIST_OAH	(1<<0)	/* original value of 'allowhook' */
 #define CIST_OAH	(1<<0)	/* original value of 'allowhook' */
 #define CIST_LUA	(1<<1)	/* call is running a Lua function */
 #define CIST_LUA	(1<<1)	/* call is running a Lua function */
 #define CIST_HOOKED	(1<<2)	/* call is running a debug hook */
 #define CIST_HOOKED	(1<<2)	/* call is running a debug hook */
-#define CIST_REENTRY	(1<<3)	/* call is running on same invocation of
-                                   luaV_execute of previous call */
+#define CIST_FRESH	(1<<3)	/* call is running on a fresh invocation
+                                   of luaV_execute */
 #define CIST_YPCALL	(1<<4)	/* call is a yieldable protected call */
 #define CIST_YPCALL	(1<<4)	/* call is a yieldable protected call */
 #define CIST_TAIL	(1<<5)	/* call was tail called */
 #define CIST_TAIL	(1<<5)	/* call was tail called */
 #define CIST_HOOKYIELD	(1<<6)	/* last hook called yielded */
 #define CIST_HOOKYIELD	(1<<6)	/* last hook called yielded */

+ 3 - 3
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 2.256 2015/10/22 14:40:47 roberto Exp roberto $
+** $Id: lvm.c,v 2.257 2015/10/28 14:50:09 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -764,6 +764,7 @@ void luaV_execute (lua_State *L) {
   LClosure *cl;
   LClosure *cl;
   TValue *k;
   TValue *k;
   StkId base;
   StkId base;
+  ci->callstatus |= CIST_FRESH;  /* fresh invocation of 'luaV_execute" */
  newframe:  /* reentry point when frame changes (call/return) */
  newframe:  /* reentry point when frame changes (call/return) */
   lua_assert(ci == L->ci);
   lua_assert(ci == L->ci);
   cl = clLvalue(ci->func);  /* local reference to function's closure */
   cl = clLvalue(ci->func);  /* local reference to function's closure */
@@ -1118,7 +1119,6 @@ void luaV_execute (lua_State *L) {
         }
         }
         else {  /* Lua function */
         else {  /* Lua function */
           ci = L->ci;
           ci = L->ci;
-          ci->callstatus |= CIST_REENTRY;
           goto newframe;  /* restart luaV_execute over new Lua function */
           goto newframe;  /* restart luaV_execute over new Lua function */
         }
         }
         vmbreak;
         vmbreak;
@@ -1158,7 +1158,7 @@ void luaV_execute (lua_State *L) {
         int b = GETARG_B(i);
         int b = GETARG_B(i);
         if (cl->p->sizep > 0) luaF_close(L, base);
         if (cl->p->sizep > 0) luaF_close(L, base);
         b = luaD_poscall(L, ra, (b != 0 ? b - 1 : cast_int(L->top - ra)));
         b = luaD_poscall(L, ra, (b != 0 ? b - 1 : cast_int(L->top - ra)));
-        if (!(ci->callstatus & CIST_REENTRY))  /* 'ci' still the called one */
+        if (ci->callstatus & CIST_FRESH)  /* local 'ci' still from callee */
           return;  /* external invocation: return */
           return;  /* external invocation: return */
         else {  /* invocation via reentry: continue execution */
         else {  /* invocation via reentry: continue execution */
           ci = L->ci;
           ci = L->ci;