summaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-03-25 10:06:36 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-03-25 10:06:36 -0300
commit3aa95981779aa8144da11f328a25bf79bd141c41 (patch)
tree7397217a9d8e89c7ed9285dc69639442a8a5f019 /lgc.c
parent64d39ed1b6c1cb749a5815002509572020424bf3 (diff)
downloadlua-3aa95981779aa8144da11f328a25bf79bd141c41.tar.gz
lua-3aa95981779aa8144da11f328a25bf79bd141c41.tar.bz2
lua-3aa95981779aa8144da11f328a25bf79bd141c41.zip
'mainthread' is not inserted in the 'allgc' list anymore, but swept
separately.
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lgc.c b/lgc.c
index fe2fafc5..9c5cdb4f 100644
--- a/lgc.c
+++ b/lgc.c
@@ -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: {