diff options
-rw-r--r-- | lgc.c | 19 | ||||
-rw-r--r-- | lgc.h | 8 | ||||
-rw-r--r-- | lstate.c | 5 | ||||
-rw-r--r-- | ltests.c | 7 |
4 files changed, 18 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.70 2010/03/24 13:07:01 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.71 2010/03/24 15:51:10 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 | */ |
@@ -572,7 +572,7 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { | |||
572 | if (gch(curr)->tt == LUA_TTHREAD) | 572 | if (gch(curr)->tt == LUA_TTHREAD) |
573 | sweepthread(L, gco2th(curr), alive); | 573 | sweepthread(L, gco2th(curr), alive); |
574 | if (!alive) { | 574 | if (!alive) { |
575 | lua_assert(isdead(g, curr) || deadmask == bitmask(SFIXEDBIT)); | 575 | lua_assert(isdead(g, curr) || deadmask == 0); |
576 | *p = gch(curr)->next; /* remove 'curr' from list */ | 576 | *p = gch(curr)->next; /* remove 'curr' from list */ |
577 | freeobj(L, curr); /* erase 'curr' */ | 577 | freeobj(L, curr); /* erase 'curr' */ |
578 | } | 578 | } |
@@ -718,11 +718,11 @@ void luaC_freeallobjects (lua_State *L) { | |||
718 | int i; | 718 | int i; |
719 | while (g->tobefnz) GCTM(L, 0); /* Call all pending finalizers */ | 719 | while (g->tobefnz) GCTM(L, 0); /* Call all pending finalizers */ |
720 | /* following "white" makes all objects look dead */ | 720 | /* following "white" makes all objects look dead */ |
721 | g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); | 721 | g->currentwhite = WHITEBITS; |
722 | sweepwholelist(L, &g->udgc); | 722 | sweepwholelist(L, &g->udgc); |
723 | lua_assert(g->udgc == NULL); | ||
723 | sweepwholelist(L, &g->allgc); | 724 | sweepwholelist(L, &g->allgc); |
724 | lua_assert(g->allgc == obj2gco(g->mainthread) && | 725 | lua_assert(g->allgc == NULL); |
725 | g->mainthread->next == NULL); | ||
726 | for (i = 0; i < g->strt.size; i++) /* free all string lists */ | 726 | for (i = 0; i < g->strt.size; i++) /* free all string lists */ |
727 | sweepwholelist(L, &g->strt.hash[i]); | 727 | sweepwholelist(L, &g->strt.hash[i]); |
728 | lua_assert(g->strt.nuse == 0); | 728 | lua_assert(g->strt.nuse == 0); |
@@ -781,14 +781,15 @@ static l_mem singlestep (lua_State *L) { | |||
781 | case GCSsweepstring: { | 781 | case GCSsweepstring: { |
782 | if (g->sweepstrgc < g->strt.size) { | 782 | if (g->sweepstrgc < g->strt.size) { |
783 | sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); | 783 | sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); |
784 | return GCSWEEPCOST; | ||
785 | } | 784 | } |
786 | else { /* nothing more to sweep */ | 785 | else { /* no more strings to sweep */ |
787 | g->sweepgc = &g->udgc; /* sweep all userdata */ | 786 | /* sweep main thread */ |
787 | sweeplist(L, cast(GCObject **, &g->mainthread), 1); | ||
788 | g->sweepgc = &g->udgc; /* prepare to sweep userdata */ | ||
788 | g->gcstate = GCSsweepudata; | 789 | g->gcstate = GCSsweepudata; |
789 | checkSizes(L); | 790 | checkSizes(L); |
790 | return 0; | ||
791 | } | 791 | } |
792 | return GCSWEEPCOST; | ||
792 | } | 793 | } |
793 | case GCSsweepudata: | 794 | case GCSsweepudata: |
794 | case GCSsweep: { | 795 | case GCSsweep: { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.28 2010/03/24 13:07:01 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.29 2010/03/24 15:51:10 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 | */ |
@@ -48,8 +48,7 @@ | |||
48 | ** bit 3 - for userdata: has been finalized | 48 | ** bit 3 - for userdata: has been finalized |
49 | ** bit 4 - for userdata: it's in 'udgc' list or in 'tobefnz' | 49 | ** bit 4 - for userdata: it's in 'udgc' list or in 'tobefnz' |
50 | ** bit 5 - object is fixed (should not be collected) | 50 | ** bit 5 - object is fixed (should not be collected) |
51 | ** bit 6 - object is "super" fixed (only the main thread) | 51 | ** bit 6 - object is old (only in generational mode) |
52 | ** bit 7 - object is old (only in generational mode) | ||
53 | */ | 52 | */ |
54 | #define WHITE0BIT 0 | 53 | #define WHITE0BIT 0 |
55 | #define WHITE1BIT 1 | 54 | #define WHITE1BIT 1 |
@@ -57,8 +56,7 @@ | |||
57 | #define FINALIZEDBIT 3 | 56 | #define FINALIZEDBIT 3 |
58 | #define SEPARATED 4 | 57 | #define SEPARATED 4 |
59 | #define FIXEDBIT 5 | 58 | #define FIXEDBIT 5 |
60 | #define SFIXEDBIT 6 | 59 | #define OLDBIT 6 |
61 | #define OLDBIT 7 | ||
62 | 60 | ||
63 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | 61 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) |
64 | 62 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.71 2010/03/22 17:45:55 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.72 2010/03/24 13:07:01 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -247,7 +247,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
247 | L->marked = luaC_white(g); | 247 | L->marked = luaC_white(g); |
248 | g->gckind = KGC_NORMAL; | 248 | g->gckind = KGC_NORMAL; |
249 | g->nCcalls = 0; | 249 | g->nCcalls = 0; |
250 | set2bits(L->marked, FIXEDBIT, SFIXEDBIT); | ||
251 | preinit_state(L, g); | 250 | preinit_state(L, g); |
252 | g->frealloc = f; | 251 | g->frealloc = f; |
253 | g->ud = ud; | 252 | g->ud = ud; |
@@ -264,7 +263,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
264 | g->panic = NULL; | 263 | g->panic = NULL; |
265 | g->version = lua_version(NULL); | 264 | g->version = lua_version(NULL); |
266 | g->gcstate = GCSpause; | 265 | g->gcstate = GCSpause; |
267 | g->allgc = obj2gco(L); | 266 | g->allgc = NULL; |
268 | g->udgc = NULL; | 267 | g->udgc = NULL; |
269 | g->tobefnz = NULL; | 268 | g->tobefnz = NULL; |
270 | g->totalbytes = sizeof(LG); | 269 | g->totalbytes = sizeof(LG); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.87 2010/01/13 16:18:25 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.88 2010/03/24 13:07:01 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 | */ |
@@ -375,11 +375,10 @@ int lua_checkmemory (lua_State *L) { | |||
375 | checkliveness(g, &g->l_registry); | 375 | checkliveness(g, &g->l_registry); |
376 | lua_assert(!isdead(g, obj2gco(g->l_gt))); | 376 | lua_assert(!isdead(g, obj2gco(g->l_gt))); |
377 | checkstack(g, g->mainthread); | 377 | checkstack(g, g->mainthread); |
378 | for (o = g->allgc; o != obj2gco(g->mainthread); o = gch(o)->next) { | 378 | for (o = g->allgc; o != NULL; o = gch(o)->next) { |
379 | lua_assert(!testbits(o->gch.marked, bit2mask(SEPARATED, SFIXEDBIT))); | 379 | lua_assert(!testbits(o->gch.marked, bitmask(SEPARATED))); |
380 | checkobject(g, o); | 380 | checkobject(g, o); |
381 | } | 381 | } |
382 | lua_assert(testbit(o->gch.marked, SFIXEDBIT)); | ||
383 | for (o = g->udgc; o != NULL; o = gch(o)->next) { | 382 | for (o = g->udgc; o != NULL; o = gch(o)->next) { |
384 | lua_assert(gch(o)->tt == LUA_TUSERDATA && | 383 | lua_assert(gch(o)->tt == LUA_TUSERDATA && |
385 | !isdead(g, o) && | 384 | !isdead(g, o) && |