Browse Source

'invalidateTMcache' not needed in all 'settable' uses

Roberto Ierusalimschy 10 years ago
parent
commit
8f25d08637
3 changed files with 7 additions and 6 deletions
  1. 2 1
      lapi.c
  2. 2 1
      lvm.c
  3. 3 4
      lvm.h

+ 2 - 1
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 2.251 2015/07/20 18:24:50 roberto Exp roberto $
+** $Id: lapi.c,v 2.252 2015/08/03 19:50:49 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -736,6 +736,7 @@ static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
   TString *str = luaS_new(L, k);
   TString *str = luaS_new(L, k);
   api_checknelems(L, 1);
   api_checknelems(L, 1);
   if (luaV_fastset(L, t, str, aux, luaH_getstr, L->top)) {
   if (luaV_fastset(L, t, str, aux, luaH_getstr, L->top)) {
+    invalidateTMcache(hvalue(t));
     setobj2t(L, cast(TValue *, aux), L->top - 1);
     setobj2t(L, cast(TValue *, aux), L->top - 1);
     L->top--;  /* pop value */
     L->top--;  /* pop value */
   }
   }

+ 2 - 1
lvm.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.c,v 2.248 2015/07/20 18:24:50 roberto Exp roberto $
+** $Id: lvm.c,v 2.249 2015/08/03 19:50:49 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -217,6 +217,7 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
     }
     }
     t = tm;  /* else repeat assignment over 'tm' */
     t = tm;  /* else repeat assignment over 'tm' */
     if (luaV_fastset(L, t, key, oldval, luaH_get, val)) {
     if (luaV_fastset(L, t, key, oldval, luaH_get, val)) {
+      invalidateTMcache(hvalue(t));
       setobj2t(L, cast(TValue *, oldval), val);
       setobj2t(L, cast(TValue *, oldval), val);
       return;
       return;
     }
     }

+ 3 - 4
lvm.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lvm.h,v 2.36 2015/07/20 18:24:50 roberto Exp roberto $
+** $Id: lvm.h,v 2.37 2015/08/03 19:50:49 roberto Exp roberto $
 ** Lua virtual machine
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -75,12 +75,11 @@
    ? (aux = NULL, 0) \
    ? (aux = NULL, 0) \
    : (aux = f(hvalue(t), k), \
    : (aux = f(hvalue(t), k), \
      ttisnil(aux) ? 0 \
      ttisnil(aux) ? 0 \
-     : (invalidateTMcache(hvalue(t)), \
-        luaC_barrierback(L, hvalue(t), v), 1)))
+     : (luaC_barrierback(L, hvalue(t), v), 1)))
 
 
 #define luaV_settable(L,t,k,v) { const TValue *aux; \
 #define luaV_settable(L,t,k,v) { const TValue *aux; \
   if (luaV_fastset(L,t,k,aux,luaH_get,v)) \
   if (luaV_fastset(L,t,k,aux,luaH_get,v)) \
-  { setobj2t(L, cast(TValue *,aux), v); } \
+  { invalidateTMcache(hvalue(t)); setobj2t(L, cast(TValue *,aux), v); } \
   else luaV_finishset(L,t,k,v,aux); }
   else luaV_finishset(L,t,k,v,aux); }