diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-09-09 10:44:07 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-09-09 10:44:07 -0300 |
| commit | b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5 (patch) | |
| tree | 5a8d2dd59066cb610534a694db8f94d45ecd3931 | |
| parent | 53be1451a850c28b9bc1e4583dccd4ecbb4478b6 (diff) | |
| download | lua-b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5.tar.gz lua-b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5.tar.bz2 lua-b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5.zip | |
'setobj2t' incorporated into 'luaV_fastset' + 'invalidateTMcache'
is not needed in the fast track (as it does not create new
entries)
| -rw-r--r-- | lvm.c | 9 | ||||
| -rw-r--r-- | lvm.h | 32 |
2 files changed, 24 insertions, 17 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.250 2015/08/03 20:40:26 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.251 2015/09/08 15:41:05 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -216,11 +216,8 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | |||
| 216 | return; | 216 | return; |
| 217 | } | 217 | } |
| 218 | t = tm; /* else repeat assignment over 'tm' */ | 218 | t = tm; /* else repeat assignment over 'tm' */ |
| 219 | if (luaV_fastset(L, t, key, oldval, luaH_get, val)) { | 219 | if (luaV_fastset(L, t, key, oldval, luaH_get, val)) |
| 220 | invalidateTMcache(hvalue(t)); | 220 | return; /* done */ |
| 221 | setobj2t(L, cast(TValue *, oldval), val); | ||
| 222 | return; | ||
| 223 | } | ||
| 224 | /* else loop */ | 221 | /* else loop */ |
| 225 | } | 222 | } |
| 226 | luaG_runerror(L, "settable chain too long; possible loop"); | 223 | luaG_runerror(L, "settable chain too long; possible loop"); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.h,v 2.37 2015/08/03 19:50:49 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.38 2015/08/03 20:40:26 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -70,17 +70,27 @@ | |||
| 70 | else luaV_finishget(L,t,k,v,aux); } | 70 | else luaV_finishget(L,t,k,v,aux); } |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | #define luaV_fastset(L,t,k,aux,f,v) \ | 73 | /* |
| 74 | ** Fast track for set table. If 't' is a table and 't[k]' is not nil, | ||
| 75 | ** call GC barrier, do a raw 't[k]=v', and return true; otherwise, | ||
| 76 | ** return false with 'slot' equal to NULL (if 't' is not a table) or | ||
| 77 | ** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro | ||
| 78 | ** returns true, there is no need to 'invalidateTMcache', because the | ||
| 79 | ** call is not creating a new entry. | ||
| 80 | */ | ||
| 81 | #define luaV_fastset(L,t,k,slot,f,v) \ | ||
| 74 | (!ttistable(t) \ | 82 | (!ttistable(t) \ |
| 75 | ? (aux = NULL, 0) \ | 83 | ? (slot = NULL, 0) \ |
| 76 | : (aux = f(hvalue(t), k), \ | 84 | : (slot = f(hvalue(t), k), \ |
| 77 | ttisnil(aux) ? 0 \ | 85 | ttisnil(slot) ? 0 \ |
| 78 | : (luaC_barrierback(L, hvalue(t), v), 1))) | 86 | : (luaC_barrierback(L, hvalue(t), v), \ |
| 79 | 87 | setobj2t(L, cast(TValue *,slot), v), \ | |
| 80 | #define luaV_settable(L,t,k,v) { const TValue *aux; \ | 88 | 1))) |
| 81 | if (luaV_fastset(L,t,k,aux,luaH_get,v)) \ | 89 | |
| 82 | { invalidateTMcache(hvalue(t)); setobj2t(L, cast(TValue *,aux), v); } \ | 90 | |
| 83 | else luaV_finishset(L,t,k,v,aux); } | 91 | #define luaV_settable(L,t,k,v) { const TValue *slot; \ |
| 92 | if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \ | ||
| 93 | luaV_finishset(L,t,k,v,slot); } | ||
| 84 | 94 | ||
| 85 | 95 | ||
| 86 | 96 | ||
