summaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-04 16:52:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-12-04 16:52:23 -0200
commitfe595a45c246faf2cf12084e7aac4b772f8f72da (patch)
tree1f2c3b54cf225f90ef4d3010c8861173d8620810 /lgc.c
parent9db1942bac5fb509c6e46ccc825351a6be546792 (diff)
downloadlua-fe595a45c246faf2cf12084e7aac4b772f8f72da.tar.gz
lua-fe595a45c246faf2cf12084e7aac4b772f8f72da.tar.bz2
lua-fe595a45c246faf2cf12084e7aac4b772f8f72da.zip
`grayagain' list
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/lgc.c b/lgc.c
index c0ebef05..ff52fa2c 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 1.184 2003/12/03 20:03:07 roberto Exp roberto $ 2** $Id: lgc.c,v 1.185 2003/12/04 17:22:42 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*/
@@ -38,6 +38,7 @@
38 38
39#define isgray(x) (!isblack(x) && !iswhite(x)) 39#define isgray(x) (!isblack(x) && !iswhite(x))
40#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) 40#define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
41#define black2gray(x) resetbit((x)->gch.marked, BLACKBIT)
41 42
42#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) 43#define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT)
43 44
@@ -323,6 +324,9 @@ static l_mem propagatemarks (global_State *g, l_mem lim) {
323 case LUA_TTHREAD: { 324 case LUA_TTHREAD: {
324 lua_State *th = gcototh(o); 325 lua_State *th = gcototh(o);
325 g->gray = th->gclist; 326 g->gray = th->gclist;
327 th->gclist = g->grayagain;
328 g->grayagain = o;
329 black2gray(o);
326 traversestack(g, th); 330 traversestack(g, th);
327 break; 331 break;
328 } 332 }
@@ -335,6 +339,11 @@ static l_mem propagatemarks (global_State *g, l_mem lim) {
335 case LUA_TUPVAL: { 339 case LUA_TUPVAL: {
336 UpVal *uv = gcotouv(o); 340 UpVal *uv = gcotouv(o);
337 g->gray = uv->gclist; 341 g->gray = uv->gclist;
342 if (uv->v != &uv->value) { /* open? */
343 uv->gclist = g->grayagain;
344 g->grayagain = o;
345 black2gray(o);
346 }
338 markvalue(g, &uv->value); 347 markvalue(g, &uv->value);
339 break; 348 break;
340 } 349 }
@@ -553,6 +562,10 @@ static void markroot (lua_State *L) {
553 562
554static void atomic (lua_State *L) { 563static void atomic (lua_State *L) {
555 global_State *g = G(L); 564 global_State *g = G(L);
565 lua_assert(g->gray == NULL);
566 g->gray = g->grayagain;
567 g->grayagain = NULL;
568 propagatemarks(g, MAXLMEM);
556 g->GCthreshold = luaC_separateudata(L); /* separate userdata to be preserved */ 569 g->GCthreshold = luaC_separateudata(L); /* separate userdata to be preserved */
557 marktmu(g); /* mark `preserved' userdata */ 570 marktmu(g); /* mark `preserved' userdata */
558 propagatemarks(g, MAXLMEM); /* remark, to propagate `preserveness' */ 571 propagatemarks(g, MAXLMEM); /* remark, to propagate `preserveness' */
@@ -565,6 +578,7 @@ static void atomic (lua_State *L) {
565 g->sweepgc = &g->rootgc->gch.next; 578 g->sweepgc = &g->rootgc->gch.next;
566 g->sweepstrgc = 0; 579 g->sweepstrgc = 0;
567 g->gcstate = GCSsweepstring; 580 g->gcstate = GCSsweepstring;
581 g->grayagain = NULL;
568} 582}
569 583
570 584