diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-11 10:18:12 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-02-11 10:18:12 -0200 |
commit | ba3586cc90d1ab8d499437dd7c504798371b0e4f (patch) | |
tree | 416f99ec601d48a19a7233f6363a7329989a6fd6 /ltests.c | |
parent | 68df7c6279421a0a5710afc31e5cd3122e0d3391 (diff) | |
download | lua-ba3586cc90d1ab8d499437dd7c504798371b0e4f.tar.gz lua-ba3586cc90d1ab8d499437dd7c504798371b0e4f.tar.bz2 lua-ba3586cc90d1ab8d499437dd7c504798371b0e4f.zip |
keep a single list of objects to be finalized (with local and non-local
objects), to ensure finalization order
Diffstat (limited to 'ltests.c')
-rw-r--r-- | ltests.c | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.161 2013/12/18 14:12:03 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.162 2013/12/30 20:47:58 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 | */ |
@@ -338,7 +338,6 @@ static void checkobject (global_State *g, GCObject *o, int maybedead) { | |||
338 | lua_assert(maybedead); | 338 | lua_assert(maybedead); |
339 | else { | 339 | else { |
340 | lua_assert(g->gcstate != GCSpause || iswhite(o)); | 340 | lua_assert(g->gcstate != GCSpause || iswhite(o)); |
341 | lua_assert(!islocal(o) || !testbit(gch(o)->marked, LOCALMARK)); | ||
342 | switch (gch(o)->tt) { | 341 | switch (gch(o)->tt) { |
343 | case LUA_TUSERDATA: { | 342 | case LUA_TUSERDATA: { |
344 | Table *mt = gco2u(o)->metatable; | 343 | Table *mt = gco2u(o)->metatable; |
@@ -456,19 +455,12 @@ int lua_checkmemory (lua_State *L) { | |||
456 | lua_assert(testbit(o->gch.marked, NOLOCALBIT)); | 455 | lua_assert(testbit(o->gch.marked, NOLOCALBIT)); |
457 | lua_assert(gch(o)->tt == LUA_TTHREAD); | 456 | lua_assert(gch(o)->tt == LUA_TTHREAD); |
458 | } | 457 | } |
459 | /* check 'localfin' list */ | ||
460 | checkgray(g, g->localfin); | ||
461 | for (o = g->localfin; o != NULL; o = gch(o)->next) { | ||
462 | checkobject(g, o, 0); | ||
463 | lua_assert(tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); | ||
464 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); | ||
465 | } | ||
466 | /* check 'finobj' list */ | 458 | /* check 'finobj' list */ |
467 | checkgray(g, g->finobj); | 459 | checkgray(g, g->finobj); |
468 | for (o = g->finobj; o != NULL; o = gch(o)->next) { | 460 | for (o = g->finobj; o != NULL; o = gch(o)->next) { |
469 | checkobject(g, o, 0); | 461 | checkobject(g, o, 0); |
470 | lua_assert(tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); | 462 | lua_assert(tofinalize(o)); |
471 | lua_assert(testbit(o->gch.marked, NOLOCALBIT)); | 463 | lua_assert(!islocal(o) || !testbit(gch(o)->marked, LOCALMARK)); |
472 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); | 464 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); |
473 | } | 465 | } |
474 | /* check 'tobefnz' list */ | 466 | /* check 'tobefnz' list */ |
@@ -655,10 +647,13 @@ static int gc_local (lua_State *L) { | |||
655 | 647 | ||
656 | static int gc_state (lua_State *L) { | 648 | static int gc_state (lua_State *L) { |
657 | static const char *statenames[] = {"propagate", "atomic", | 649 | static const char *statenames[] = {"propagate", "atomic", |
658 | "sweeplocalgc", "sweepallgc", "sweepthreads", "sweeplocalfin", | 650 | "sweeplocalgc", "sweepallgc", "sweepthreads", "sweepfinobj", |
659 | "sweepfinobj", "sweeptobefnz", "sweepend", "pause", ""}; | 651 | "sweeptobefnz", "sweepend", "pause", ""}; |
660 | int option = luaL_checkoption(L, 1, "", statenames); | 652 | static const int states[] = {GCSpropagate, GCSatomic, |
661 | if (option == GCSpause + 1) { | 653 | GCSswplocalgc, GCSswpallgc, GCSswpthreads, GCSswpfinobj, |
654 | GCSswptobefnz, GCSswpend, GCSpause, -1}; | ||
655 | int option = states[luaL_checkoption(L, 1, "", statenames)]; | ||
656 | if (option == -1) { | ||
662 | lua_pushstring(L, statenames[G(L)->gcstate]); | 657 | lua_pushstring(L, statenames[G(L)->gcstate]); |
663 | return 1; | 658 | return 1; |
664 | } | 659 | } |