diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-03 08:55:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-03 08:55:40 -0300 |
commit | d25f7f9d78961543cbbcc0f793e37631030d003c (patch) | |
tree | 8cfe603c0b22e051a8b1dc7f30d6a1431896e3e0 | |
parent | 85555646e3e8e1db4f50772ff8ef5c55908cc165 (diff) | |
download | lua-d25f7f9d78961543cbbcc0f793e37631030d003c.tar.gz lua-d25f7f9d78961543cbbcc0f793e37631030d003c.tar.bz2 lua-d25f7f9d78961543cbbcc0f793e37631030d003c.zip |
items in 'tobefnz' are kept black (as before recent change) and changed
to white only when needed (being moved to 'allgc' when not keeping
invariant).
-rw-r--r-- | lgc.c | 19 | ||||
-rw-r--r-- | ltests.c | 5 |
2 files changed, 15 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.82 2010/04/29 21:43:36 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.83 2010/04/30 18:37:14 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 | */ |
@@ -265,7 +265,8 @@ static void markbeingfnz (global_State *g) { | |||
265 | GCObject *o; | 265 | GCObject *o; |
266 | for (o = g->tobefnz; o != NULL; o = gch(o)->next) { | 266 | for (o = g->tobefnz; o != NULL; o = gch(o)->next) { |
267 | lua_assert(testbit(gch(o)->marked, SEPARATED)); | 267 | lua_assert(testbit(gch(o)->marked, SEPARATED)); |
268 | markobject(g, o); | 268 | makewhite(g, o); |
269 | reallymarkobject(g, o); | ||
269 | } | 270 | } |
270 | } | 271 | } |
271 | 272 | ||
@@ -651,12 +652,15 @@ static void checkSizes (lua_State *L) { | |||
651 | 652 | ||
652 | static Udata *udata2finalize (global_State *g) { | 653 | static Udata *udata2finalize (global_State *g) { |
653 | GCObject *o = g->tobefnz; /* get first element */ | 654 | GCObject *o = g->tobefnz; /* get first element */ |
654 | g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */ | 655 | Udata *u = rawgco2u(o); |
655 | gch(o)->next = g->allgc; /* return it to 'allgc' list */ | 656 | lua_assert(isfinalized(&u->uv)); |
657 | g->tobefnz = u->uv.next; /* remove it from 'tobefnz' list */ | ||
658 | u->uv.next = g->allgc; /* return it to 'allgc' list */ | ||
656 | g->allgc = o; | 659 | g->allgc = o; |
657 | lua_assert(isfinalized(gch(o))); | 660 | resetbit(u->uv.marked, SEPARATED); /* mark that it is not in 'tobefnz' */ |
658 | resetbit(gch(o)->marked, SEPARATED); /* mark it as such */ | 661 | if (!keepinvariant(g)) /* not keeping invariant? */ |
659 | return rawgco2u(o); | 662 | makewhite(g, o); /* "sweep" object */ |
663 | return u; | ||
660 | } | 664 | } |
661 | 665 | ||
662 | 666 | ||
@@ -833,7 +837,6 @@ static l_mem singlestep (lua_State *L) { | |||
833 | return GCSWEEPMAX*GCSWEEPCOST; | 837 | return GCSWEEPMAX*GCSWEEPCOST; |
834 | } | 838 | } |
835 | else { | 839 | else { |
836 | sweepwholelist(L, &g->tobefnz); /* sweep 'to-be-finalized' list */ | ||
837 | g->sweepgc = &g->allgc; /* go to next phase */ | 840 | g->sweepgc = &g->allgc; /* go to next phase */ |
838 | g->gcstate = GCSsweep; | 841 | g->gcstate = GCSsweep; |
839 | return GCSWEEPCOST; | 842 | return GCSWEEPCOST; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.98 2010/04/29 21:42:33 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.99 2010/04/30 18:37:14 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 | */ |
@@ -412,6 +412,9 @@ int lua_checkmemory (lua_State *L) { | |||
412 | testbit(o->gch.marked, SEPARATED)); | 412 | testbit(o->gch.marked, SEPARATED)); |
413 | checkobject(g, o); | 413 | checkobject(g, o); |
414 | } | 414 | } |
415 | for (o = g->tobefnz; o != NULL; o = gch(o)->next) { | ||
416 | lua_assert(gch(o)->tt == LUA_TUSERDATA && isblack(o)); | ||
417 | } | ||
415 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { | 418 | for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { |
416 | lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); | 419 | lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); |
417 | lua_assert(uv->v != &uv->u.value); /* must be open */ | 420 | lua_assert(uv->v != &uv->u.value); /* must be open */ |