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 /ltests.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 '')
| -rw-r--r-- | ltests.c | 19 |
1 files changed, 7 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 2.139 2013/06/20 21:59:13 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.140 2013/08/05 16:58:28 roberto Exp roberto $ |
| 3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -310,7 +310,7 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
| 310 | lua_assert(!isdead(g, obj2gco(L1))); | 310 | lua_assert(!isdead(g, obj2gco(L1))); |
| 311 | for (uvo = L1->openupval; uvo != NULL; uvo = gch(uvo)->next) { | 311 | for (uvo = L1->openupval; uvo != NULL; uvo = gch(uvo)->next) { |
| 312 | UpVal *uv = gco2uv(uvo); | 312 | UpVal *uv = gco2uv(uvo); |
| 313 | lua_assert(uv->v != &uv->u.value); /* must be open */ | 313 | lua_assert(uv->v != &uv->value); /* must be open */ |
| 314 | lua_assert(!isblack(uvo)); /* open upvalues cannot be black */ | 314 | lua_assert(!isblack(uvo)); /* open upvalues cannot be black */ |
| 315 | } | 315 | } |
| 316 | for (ci = L1->ci; ci != NULL; ci = ci->previous) { | 316 | for (ci = L1->ci; ci != NULL; ci = ci->previous) { |
| @@ -334,7 +334,7 @@ static void checkobject (global_State *g, GCObject *o, int maybedead) { | |||
| 334 | switch (gch(o)->tt) { | 334 | switch (gch(o)->tt) { |
| 335 | case LUA_TUPVAL: { | 335 | case LUA_TUPVAL: { |
| 336 | UpVal *uv = gco2uv(o); | 336 | UpVal *uv = gco2uv(o); |
| 337 | lua_assert(uv->v == &uv->u.value); /* must be closed */ | 337 | lua_assert(uv->v == &uv->value); /* must be closed */ |
| 338 | lua_assert(!isgray(o)); /* closed upvalues are never gray */ | 338 | lua_assert(!isgray(o)); /* closed upvalues are never gray */ |
| 339 | checkvalref(g, o, uv->v); | 339 | checkvalref(g, o, uv->v); |
| 340 | break; | 340 | break; |
| @@ -419,8 +419,8 @@ static void checkgray (global_State *g, GCObject *o) { | |||
| 419 | int lua_checkmemory (lua_State *L) { | 419 | int lua_checkmemory (lua_State *L) { |
| 420 | global_State *g = G(L); | 420 | global_State *g = G(L); |
| 421 | GCObject *o; | 421 | GCObject *o; |
| 422 | UpVal *uv; | ||
| 423 | int maybedead; | 422 | int maybedead; |
| 423 | int isthread; | ||
| 424 | if (keepinvariant(g)) { | 424 | if (keepinvariant(g)) { |
| 425 | lua_assert(!iswhite(obj2gco(g->mainthread))); | 425 | lua_assert(!iswhite(obj2gco(g->mainthread))); |
| 426 | lua_assert(!iswhite(gcvalue(&g->l_registry))); | 426 | lua_assert(!iswhite(gcvalue(&g->l_registry))); |
| @@ -433,9 +433,12 @@ int lua_checkmemory (lua_State *L) { | |||
| 433 | checkgray(g, g->allgc); | 433 | checkgray(g, g->allgc); |
| 434 | lua_assert(g->sweepgc == NULL || issweepphase(g)); | 434 | lua_assert(g->sweepgc == NULL || issweepphase(g)); |
| 435 | maybedead = 0; | 435 | maybedead = 0; |
| 436 | isthread = 0; /* not traversing threads (yet) */ | ||
| 436 | for (o = g->allgc; o != NULL; o = gch(o)->next) { | 437 | for (o = g->allgc; o != NULL; o = gch(o)->next) { |
| 437 | if (g->sweepgc && o == *g->sweepgc) | 438 | if (g->sweepgc && o == *g->sweepgc) |
| 438 | maybedead = 1; /* part of the list not yet swept */ | 439 | maybedead = 1; /* part of the list not yet swept */ |
| 440 | if (gch(o)->tt == LUA_TTHREAD) isthread = 1; /* now travesing threads... */ | ||
| 441 | else lua_assert(!isthread); /* ... and only threads */ | ||
| 439 | checkobject(g, o, maybedead); | 442 | checkobject(g, o, maybedead); |
| 440 | lua_assert(!testbit(o->gch.marked, SEPARATED)); | 443 | lua_assert(!testbit(o->gch.marked, SEPARATED)); |
| 441 | } | 444 | } |
| @@ -455,14 +458,6 @@ int lua_checkmemory (lua_State *L) { | |||
| 455 | lua_assert(gch(o)->tt == LUA_TUSERDATA || | 458 | lua_assert(gch(o)->tt == LUA_TUSERDATA || |
| 456 | gch(o)->tt == LUA_TTABLE); | 459 | gch(o)->tt == LUA_TTABLE); |
| 457 | } | 460 | } |
| 458 | /* check 'uvhead' list */ | ||
| 459 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { | ||
| 460 | lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); | ||
| 461 | lua_assert(uv->v != &uv->u.value); /* must be open */ | ||
| 462 | lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */ | ||
| 463 | if (!isdead(g, obj2gco(uv))) | ||
| 464 | checkvalref(g, obj2gco(uv), uv->v); | ||
| 465 | } | ||
| 466 | return 0; | 461 | return 0; |
| 467 | } | 462 | } |
| 468 | 463 | ||
