Kaynağa Gözat

Undo change in the handling of 'L->top' (commit b80077b8f3)

With MMBIN instructions, there are fewer opcodes that need to update
'L->top', so that change does not seem to pay for the increased
complexity.
Roberto Ierusalimschy 6 yıl önce
ebeveyn
işleme
72a094bda7
4 değiştirilmiş dosya ile 9 ekleme ve 16 silme
  1. 0 2
      lapi.c
  2. 0 2
      lobject.c
  3. 0 2
      ltm.c
  4. 9 10
      lvm.c

+ 0 - 2
lapi.c

@@ -329,14 +329,12 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op) {
   o1 = index2value(L, index1);
   o2 = index2value(L, index2);
   if (isvalid(L, o1) && isvalid(L, o2)) {
-    ptrdiff_t top = savestack(L, L->top);
     switch (op) {
       case LUA_OPEQ: i = luaV_equalobj(L, o1, o2); break;
       case LUA_OPLT: i = luaV_lessthan(L, o1, o2); break;
       case LUA_OPLE: i = luaV_lessequal(L, o1, o2); break;
       default: api_check(L, 0, "invalid option");
     }
-    L->top = restorestack(L, top);
   }
   lua_unlock(L);
   return i;

+ 0 - 2
lobject.c

@@ -127,9 +127,7 @@ void luaO_arith (lua_State *L, int op, const TValue *p1, const TValue *p2,
                  StkId res) {
   if (!luaO_rawarith(L, op, p1, p2, s2v(res))) {
     /* could not perform raw operation; try metamethod */
-    ptrdiff_t top = savestack(L, L->top);
     luaT_trybinTM(L, p1, p2, res, cast(TMS, (op - LUA_OPADD) + TM_ADD));
-    L->top = restorestack(L, top);
   }
 }
 

+ 0 - 2
ltm.c

@@ -147,7 +147,6 @@ static int callbinTM (lua_State *L, const TValue *p1, const TValue *p2,
 
 void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
                     StkId res, TMS event) {
-  L->top = L->ci->top;
   if (!callbinTM(L, p1, p2, res, event)) {
     switch (event) {
       case TM_BAND: case TM_BOR: case TM_BXOR:
@@ -191,7 +190,6 @@ void luaT_trybiniTM (lua_State *L, const TValue *p1, lua_Integer i2,
 
 int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2,
                       TMS event) {
-  L->top = L->ci->top;
   if (callbinTM(L, p1, p2, L->top, event))  /* try original event */
     return !l_isfalse(s2v(L->top));
 #if defined(LUA_COMPAT_LT_LE)

+ 9 - 10
lvm.c

@@ -516,7 +516,6 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
   if (tm == NULL)  /* no TM? */
     return 0;  /* objects are different */
   else {
-    L->top = L->ci->top;
     luaT_callTMres(L, tm, t1, t2, L->top);  /* call TM */
     return !l_isfalse(s2v(L->top));
   }
@@ -925,7 +924,7 @@ void luaV_finishOp (lua_State *L) {
         else if (ttisnumber(s2v(ra)) && ttisnumber(rb))  \
           cond = opf(s2v(ra), rb);  \
         else  \
-          ProtectNT(cond = other(L, s2v(ra), rb));  \
+          Protect(cond = other(L, s2v(ra), rb));  \
         docondjump(); }
 
 
@@ -944,7 +943,7 @@ void luaV_finishOp (lua_State *L) {
         }  \
         else {  \
           int isf = GETARG_C(i);  \
-          ProtectNT(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm));  \
+          Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm));  \
         }  \
         docondjump(); }
 
@@ -989,7 +988,7 @@ void luaV_finishOp (lua_State *L) {
 
 
 /* for test instructions, execute the jump instruction that follows it */
-#define donextjump(ci)	{ i = *pc; dojump(ci, i, 1); }
+#define donextjump(ci)	{ Instruction ni = *pc; dojump(ci, ni, 1); }
 
 /*
 ** do a conditional jump: skip next instruction if 'cond' is not what
@@ -1408,7 +1407,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
         TMS tm = (TMS)GETARG_C(i);
         StkId result = RA(pi);
         lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
-        ProtectNT(luaT_trybinTM(L, s2v(ra), rb, result, tm));
+        Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
         vmbreak;
       }
       vmcase(OP_MMBINI) {
@@ -1417,7 +1416,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
         TMS tm = (TMS)GETARG_C(i);
         int flip = GETARG_k(i);
         StkId result = RA(pi);
-        ProtectNT(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
+        Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
         vmbreak;
       }
       vmcase(OP_MMBINK) {
@@ -1426,7 +1425,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
         TMS tm = (TMS)GETARG_C(i);
         int flip = GETARG_k(i);
         StkId result = RA(pi);
-        ProtectNT(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
+        Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
         vmbreak;
       }
       vmcase(OP_UNM) {
@@ -1440,7 +1439,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
           setfltvalue(s2v(ra), luai_numunm(L, nb));
         }
         else
-          ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
+          Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
         vmbreak;
       }
       vmcase(OP_BNOT) {
@@ -1450,7 +1449,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
           setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
         }
         else
-          ProtectNT(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
+          Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
         vmbreak;
       }
       vmcase(OP_NOT) {
@@ -1486,7 +1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
       vmcase(OP_EQ) {
         int cond;
         TValue *rb = vRB(i);
-        ProtectNT(cond = luaV_equalobj(L, s2v(ra), rb));
+        Protect(cond = luaV_equalobj(L, s2v(ra), rb));
         docondjump();
         vmbreak;
       }