diff options
| -rw-r--r-- | lgc.c | 24 | ||||
| -rw-r--r-- | lgc.h | 5 | ||||
| -rw-r--r-- | lvm.c | 12 |
3 files changed, 8 insertions, 33 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.145 2013/08/13 17:36:44 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.146 2013/08/16 18:55:49 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -172,28 +172,6 @@ void luaC_barrierback_ (lua_State *L, GCObject *o) { | |||
| 172 | 172 | ||
| 173 | 173 | ||
| 174 | /* | 174 | /* |
| 175 | ** barrier for prototypes. When creating first closure (cache is | ||
| 176 | ** NULL), use a forward barrier; this may be the only closure of the | ||
| 177 | ** prototype (if it is a "regular" function, with a single instance) | ||
| 178 | ** and the prototype may be big, so it is better to avoid traversing | ||
| 179 | ** it again. Otherwise, use a backward barrier, to avoid marking all | ||
| 180 | ** possible instances. | ||
| 181 | */ | ||
| 182 | LUAI_FUNC void luaC_barrierproto_ (lua_State *L, Proto *p, Closure *c) { | ||
| 183 | global_State *g = G(L); | ||
| 184 | lua_assert(isblack(obj2gco(p))); | ||
| 185 | if (p->cache == NULL) { /* first time? */ | ||
| 186 | luaC_objbarrier(L, p, c); | ||
| 187 | } | ||
| 188 | else { /* use a backward barrier */ | ||
| 189 | black2gray(obj2gco(p)); /* make prototype gray (again) */ | ||
| 190 | p->gclist = g->grayagain; | ||
| 191 | g->grayagain = obj2gco(p); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | |||
| 196 | /* | ||
| 197 | ** check color (and invariants) for an upvalue that is being closed, | 175 | ** check color (and invariants) for an upvalue that is being closed, |
| 198 | ** i.e., moved into the 'allgc' list | 176 | ** i.e., moved into the 'allgc' list |
| 199 | */ | 177 | */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.h,v 2.60 2013/08/13 17:36:44 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.61 2013/08/16 18:55:49 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -128,9 +128,6 @@ | |||
| 128 | { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ | 128 | { if (nolocal(obj2gco(o)), isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ |
| 129 | luaC_barrierback_(L,p); } | 129 | luaC_barrierback_(L,p); } |
| 130 | 130 | ||
| 131 | #define luaC_barrierproto(L,p,c) \ | ||
| 132 | { if (nolocal(obj2gco(c)), isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } | ||
| 133 | |||
| 134 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); | 131 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); |
| 135 | LUAI_FUNC void luaC_step (lua_State *L); | 132 | LUAI_FUNC void luaC_step (lua_State *L); |
| 136 | LUAI_FUNC void luaC_forcestep (lua_State *L); | 133 | LUAI_FUNC void luaC_forcestep (lua_State *L); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.176 2013/07/10 17:15:12 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.177 2013/08/16 18:55:49 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 | */ |
| @@ -399,9 +399,9 @@ static Closure *getcached (Proto *p, UpVal **encup, StkId base) { | |||
| 399 | 399 | ||
| 400 | /* | 400 | /* |
| 401 | ** create a new Lua closure, push it in the stack, and initialize | 401 | ** create a new Lua closure, push it in the stack, and initialize |
| 402 | ** its upvalues. Note that the call to 'luaC_barrierproto' must come | 402 | ** its upvalues. Note that the closure is not cached if prototype is |
| 403 | ** before the assignment to 'p->cache', as the function needs the | 403 | ** already black (which means that 'cache' was already cleared by the |
| 404 | ** original value of that field. | 404 | ** GC). |
| 405 | */ | 405 | */ |
| 406 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | 406 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
| 407 | StkId ra) { | 407 | StkId ra) { |
| @@ -418,8 +418,8 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | |||
| 418 | ncl->l.upvals[i] = encup[uv[i].idx]; | 418 | ncl->l.upvals[i] = encup[uv[i].idx]; |
| 419 | /* new closure is white and local, so we do not need a barrier here */ | 419 | /* new closure is white and local, so we do not need a barrier here */ |
| 420 | } | 420 | } |
| 421 | luaC_barrierproto(L, p, ncl); | 421 | if (!isblack(obj2gco(p))) /* cache will not break GC invariant? */ |
| 422 | p->cache = ncl; /* save it on cache for reuse */ | 422 | p->cache = ncl; /* save it on cache for reuse */ |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | 425 | ||
