aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-03 10:30:41 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-03 10:30:41 -0200
commit8878554b854009066eeccfe7b17e6e019c69758a (patch)
tree3e1bd9eb96e66daf73718b633ddb3e1b82d4c98c /lgc.c
parentaf850484a9e01b46b04e4c666f9a9e91308d81c7 (diff)
downloadlua-8878554b854009066eeccfe7b17e6e019c69758a.tar.gz
lua-8878554b854009066eeccfe7b17e6e019c69758a.tar.bz2
lua-8878554b854009066eeccfe7b17e6e019c69758a.zip
single list for all collectible objects, with udata separated at the
end of the list
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lgc.c b/lgc.c
index f8fdcb4c..8f56b479 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.181 2003/12/01 16:33:30 roberto Exp roberto $ 2** $Id: lgc.c,v 1.182 2003/12/01 18:22:56 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*/
@@ -158,7 +158,7 @@ static void marktmu (global_State *g) {
158/* move `dead' udata that need finalization to list `tmudata' */ 158/* move `dead' udata that need finalization to list `tmudata' */
159size_t luaC_separateudata (lua_State *L) { 159size_t luaC_separateudata (lua_State *L) {
160 size_t deadmem = 0; 160 size_t deadmem = 0;
161 GCObject **p = &G(L)->rootudata; 161 GCObject **p = &G(L)->firstudata;
162 GCObject *curr; 162 GCObject *curr;
163 GCObject *collected = NULL; /* to collect udata with gc event */ 163 GCObject *collected = NULL; /* to collect udata with gc event */
164 GCObject **lastcollected = &collected; 164 GCObject **lastcollected = &collected;
@@ -495,8 +495,8 @@ static void GCTM (lua_State *L) {
495 Udata *udata = gcotou(o); 495 Udata *udata = gcotou(o);
496 const TObject *tm; 496 const TObject *tm;
497 g->tmudata = udata->uv.next; /* remove udata from `tmudata' */ 497 g->tmudata = udata->uv.next; /* remove udata from `tmudata' */
498 udata->uv.next = g->rootudata; /* return it to `root' list */ 498 udata->uv.next = g->firstudata->uv.next; /* return it to `root' list */
499 g->rootudata = o; 499 g->firstudata->uv.next = o;
500 makewhite(o); 500 makewhite(o);
501 tm = fasttm(L, udata->uv.metatable, TM_GC); 501 tm = fasttm(L, udata->uv.metatable, TM_GC);
502 if (tm != NULL) { 502 if (tm != NULL) {
@@ -524,7 +524,6 @@ void luaC_callGCTM (lua_State *L) {
524void luaC_sweepall (lua_State *L) { 524void luaC_sweepall (lua_State *L) {
525 l_mem dummy = MAXLMEM; 525 l_mem dummy = MAXLMEM;
526 sweepstrings(L, 0); 526 sweepstrings(L, 0);
527 sweeplist(L, &G(L)->rootudata, 0, &dummy);
528 sweeplist(L, &G(L)->rootgc, 0, &dummy); 527 sweeplist(L, &G(L)->rootgc, 0, &dummy);
529} 528}
530 529
@@ -537,8 +536,8 @@ static void markroot (lua_State *L) {
537 makewhite(valtogco(g->mainthread)); 536 makewhite(valtogco(g->mainthread));
538 markobject(g, g->mainthread); 537 markobject(g, g->mainthread);
539 markvalue(g, registry(L)); 538 markvalue(g, registry(L));
540 if (L != g->mainthread) /* another thread is running? */ 539 markobject(g, g->firstudata);
541 markobject(g, L); /* cannot collect it */ 540 markobject(g, L); /* mark running thread */
542 g->gcstate = GCSpropagate; 541 g->gcstate = GCSpropagate;
543} 542}
544 543
@@ -549,8 +548,10 @@ static void atomic (lua_State *L) {
549 marktmu(g); /* mark `preserved' userdata */ 548 marktmu(g); /* mark `preserved' userdata */
550 propagatemarks(g, MAXLMEM); /* remark, to propagate `preserveness' */ 549 propagatemarks(g, MAXLMEM); /* remark, to propagate `preserveness' */
551 cleartable(g->weak); /* remove collected objects from weak tables */ 550 cleartable(g->weak); /* remove collected objects from weak tables */
552 g->sweepgc = &g->rootgc; 551 /* first element of root list will be used as temporary head for sweep
553 g->sweepudata = &g->rootudata; 552 phase, so it won't be seeped */
553 makewhite(g->rootgc);
554 g->sweepgc = &g->rootgc->gch.next;
554 sweepstrings(L, maskbf); 555 sweepstrings(L, maskbf);
555 g->gcstate = GCSsweep; 556 g->gcstate = GCSsweep;
556} 557}
@@ -559,7 +560,6 @@ static void atomic (lua_State *L) {
559static void sweepstep (lua_State *L) { 560static void sweepstep (lua_State *L) {
560 global_State *g = G(L); 561 global_State *g = G(L);
561 l_mem lim = GCSTEPSIZE; 562 l_mem lim = GCSTEPSIZE;
562 g->sweepudata = sweeplist(L, g->sweepudata, maskbf, &lim);
563 g->sweepgc = sweeplist(L, g->sweepgc, maskbf, &lim); 563 g->sweepgc = sweeplist(L, g->sweepgc, maskbf, &lim);
564 if (lim == GCSTEPSIZE) { /* nothing more to sweep? */ 564 if (lim == GCSTEPSIZE) { /* nothing more to sweep? */
565 g->gcstate = GCSfinalize; /* end sweep phase */ 565 g->gcstate = GCSfinalize; /* end sweep phase */