diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-07 09:18:11 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-08-07 09:18:11 -0300 |
| commit | 623e388bb4c75eb07af3b7f83c736841d9fb76f0 (patch) | |
| tree | f0c64d3c1b0f385b1b31536dd46ccd0c55b57a0b /lgc.c | |
| parent | 677d90165ffef728231340c6328e9661824dbc34 (diff) | |
| download | lua-623e388bb4c75eb07af3b7f83c736841d9fb76f0.tar.gz lua-623e388bb4c75eb07af3b7f83c736841d9fb76f0.tar.bz2 lua-623e388bb4c75eb07af3b7f83c736841d9fb76f0.zip | |
double-linked list of all upvalues elliminated and changed to a
traversal of all non-marked threads
Diffstat (limited to 'lgc.c')
| -rw-r--r-- | lgc.c | 25 |
1 files changed, 16 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.141 2013/04/26 18:26:49 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.142 2013/08/05 16:58:28 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 | */ |
| @@ -258,7 +258,7 @@ static void reallymarkobject (global_State *g, GCObject *o) { | |||
| 258 | case LUA_TUPVAL: { | 258 | case LUA_TUPVAL: { |
| 259 | UpVal *uv = gco2uv(o); | 259 | UpVal *uv = gco2uv(o); |
| 260 | markvalue(g, uv->v); | 260 | markvalue(g, uv->v); |
| 261 | if (uv->v != &uv->u.value) /* open? */ | 261 | if (uv->v != &uv->value) /* open? */ |
| 262 | return; /* open upvalues remain gray */ | 262 | return; /* open upvalues remain gray */ |
| 263 | size = sizeof(UpVal); | 263 | size = sizeof(UpVal); |
| 264 | break; | 264 | break; |
| @@ -317,14 +317,21 @@ static void markbeingfnz (global_State *g) { | |||
| 317 | 317 | ||
| 318 | 318 | ||
| 319 | /* | 319 | /* |
| 320 | ** mark all values stored in marked open upvalues. (See comment in | 320 | ** Mark all values stored in marked open upvalues from non-marked threads. |
| 321 | ** 'lstate.h'.) | 321 | ** (Values from marked threads were already marked when traversing the |
| 322 | ** thread.) | ||
| 322 | */ | 323 | */ |
| 323 | static void remarkupvals (global_State *g) { | 324 | static void remarkupvals (global_State *g) { |
| 324 | UpVal *uv; | 325 | GCObject *thread = hvalue(&g->l_registry)->next; |
| 325 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { | 326 | for (; thread != NULL; thread = gch(thread)->next) { |
| 326 | if (isgray(obj2gco(uv))) | 327 | lua_assert(!isblack(thread)); /* threads are never black */ |
| 327 | markvalue(g, uv->v); | 328 | if (!isgray(thread)) { /* dead thread? */ |
| 329 | GCObject *uv = gco2th(thread)->openupval; | ||
| 330 | for (; uv != NULL; uv = gch(uv)->next) { | ||
| 331 | if (isgray(uv)) /* marked? */ | ||
| 332 | markvalue(g, gco2uv(uv)->v); /* remark upvalue's value */ | ||
| 333 | } | ||
| 334 | } | ||
| 328 | } | 335 | } |
| 329 | } | 336 | } |
| 330 | 337 | ||
| @@ -669,7 +676,7 @@ static void freeobj (lua_State *L, GCObject *o) { | |||
| 669 | luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); | 676 | luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); |
| 670 | break; | 677 | break; |
| 671 | } | 678 | } |
| 672 | case LUA_TUPVAL: luaF_freeupval(L, gco2uv(o)); break; | 679 | case LUA_TUPVAL: luaM_free(L, gco2uv(o)); break; |
| 673 | case LUA_TTABLE: luaH_free(L, gco2t(o)); break; | 680 | case LUA_TTABLE: luaH_free(L, gco2t(o)); break; |
| 674 | case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; | 681 | case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; |
| 675 | case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; | 682 | case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; |
