1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00

cannot sweep main thread in sweepstring phase

This commit is contained in:
Roberto Ierusalimschy 2010-04-05 11:15:35 -03:00
parent f80ff7a336
commit a09c8d7beb

23
lgc.c
View File

@ -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 ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -778,25 +778,34 @@ static l_mem singlestep (lua_State *L) {
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
} }
else { /* no more strings to sweep */ 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->sweepgc = &g->udgc; /* prepare to sweep userdata */
g->gcstate = GCSsweepudata; g->gcstate = GCSsweepudata;
} }
return GCSWEEPCOST; return GCSWEEPCOST;
} }
case GCSsweepudata: case GCSsweepudata: {
case GCSsweep: {
if (*g->sweepgc) { if (*g->sweepgc) {
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST; return GCSWEEPMAX*GCSWEEPCOST;
} }
else { /* go to next phase */ else { /* go to next phase */
g->sweepgc = &g->allgc; /* useless (but harmless) in GCSsweep case */ g->sweepgc = &g->allgc;
g->gcstate = (g->gcstate == GCSsweep) ? GCSfinalize : GCSsweep; g->gcstate = GCSsweep;
return 0; 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: { case GCSfinalize: {
if (g->tobefnz) { if (g->tobefnz) {
GCTM(L, 1); GCTM(L, 1);