Browse Source

don't need to mark the stacks twice ;-)

v5-2
Roberto Ierusalimschy 23 years ago
parent
commit
19ac0fadc9
  1. 12
      lgc.c

12
lgc.c

@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 1.130 2002/03/07 18:14:29 roberto Exp roberto $ ** $Id: lgc.c,v 1.131 2002/03/20 18:37:28 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -234,10 +234,7 @@ static void traversetable (GCState *st, Table *h) {
} }
static void markall (GCState *st) { static void propagatemarks (GCState *st) {
lua_assert(hvalue(defaultmeta(st->L))->flags == cast(unsigned short, ~0));
/* table is unchanged */
markstacks(st); /* mark all stacks */
while (st->tmark) { /* traverse marked tables */ while (st->tmark) { /* traverse marked tables */
Table *h = st->tmark; /* get first table from list */ Table *h = st->tmark; /* get first table from list */
st->tmark = h->mark; /* remove it from list */ st->tmark = h->mark; /* remove it from list */
@ -456,10 +453,11 @@ void luaC_collectgarbage (lua_State *L) {
st.L = L; st.L = L;
st.tmark = NULL; st.tmark = NULL;
st.toclear = NULL; st.toclear = NULL;
markall(&st); /* mark all reachable objects */ markstacks(&st); /* mark all stacks */
propagatemarks(&st); /* mark all reachable objects */
separateudata(L); /* separate userdata to be preserved */ separateudata(L); /* separate userdata to be preserved */
marktmu(&st); /* mark `preserved' userdata */ marktmu(&st); /* mark `preserved' userdata */
markall(&st); /* remark */ propagatemarks(&st); /* remark */
cleartables(st.toclear); cleartables(st.toclear);
luaC_collect(L, 0); luaC_collect(L, 0);
checkMbuffer(L); checkMbuffer(L);

Loading…
Cancel
Save