commit a09c8d7beb79611a7bc5f2b6f8255cc18b0feef3
parent f80ff7a336bc604feb410be691350c19edb3f00e
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 5 Apr 2010 11:15:11 -0300
cannot sweep main thread in sweepstring phase
Diffstat:
M | lgc.c | | | 23 | ++++++++++++++++------- |
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/lgc.c b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.75 2010/03/29 17:43:14 roberto Exp roberto $
+** $Id: lgc.c,v 2.76 2010/04/02 14:37:41 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -778,25 +778,34 @@ static l_mem singlestep (lua_State *L) {
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
}
else { /* no more strings to sweep */
- /* sweep main thread */
- sweeplist(L, cast(GCObject **, &g->mainthread), 1);
g->sweepgc = &g->udgc; /* prepare to sweep userdata */
g->gcstate = GCSsweepudata;
}
return GCSWEEPCOST;
}
- case GCSsweepudata:
- case GCSsweep: {
+ case GCSsweepudata: {
if (*g->sweepgc) {
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST;
}
else { /* go to next phase */
- g->sweepgc = &g->allgc; /* useless (but harmless) in GCSsweep case */
- g->gcstate = (g->gcstate == GCSsweep) ? GCSfinalize : GCSsweep;
+ g->sweepgc = &g->allgc;
+ g->gcstate = GCSsweep;
return 0;
}
}
+ case GCSsweep: {
+ if (*g->sweepgc) {
+ g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
+ return GCSWEEPMAX*GCSWEEPCOST;
+ }
+ else {
+ /* sweep main thread */
+ sweeplist(L, cast(GCObject **, &g->mainthread), 1);
+ g->gcstate = GCSfinalize; /* go to next phase */
+ return GCSWEEPCOST;
+ }
+ }
case GCSfinalize: {
if (g->tobefnz) {
GCTM(L, 1);