aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lgc.c b/lgc.c
index 6beaa55b..1273d58d 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.10 2004/08/30 13:44:44 roberto Exp roberto $ 2** $Id: lgc.c,v 2.11 2004/09/08 14:23:09 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*/
@@ -499,7 +499,7 @@ void luaC_freeall (lua_State *L) {
499/* mark root set */ 499/* mark root set */
500static void markroot (lua_State *L) { 500static void markroot (lua_State *L) {
501 global_State *g = G(L); 501 global_State *g = G(L);
502 lua_assert(g->gray == NULL); 502 g->gray = NULL;
503 g->grayagain = NULL; 503 g->grayagain = NULL;
504 g->weak = NULL; 504 g->weak = NULL;
505 markobject(g, g->mainthread); 505 markobject(g, g->mainthread);
@@ -513,6 +513,7 @@ static void markroot (lua_State *L) {
513static void remarkupvals (global_State *g) { 513static void remarkupvals (global_State *g) {
514 GCObject *o; 514 GCObject *o;
515 for (o = obj2gco(g->mainthread); o; o = o->gch.next) { 515 for (o = obj2gco(g->mainthread); o; o = o->gch.next) {
516 lua_assert(!isblack(o));
516 if (iswhite(o)) { 517 if (iswhite(o)) {
517 GCObject *curr; 518 GCObject *curr;
518 for (curr = gco2th(o)->openupval; curr != NULL; curr = curr->gch.next) { 519 for (curr = gco2th(o)->openupval; curr != NULL; curr = curr->gch.next) {
@@ -529,7 +530,8 @@ static void remarkupvals (global_State *g) {
529static void atomic (lua_State *L) { 530static void atomic (lua_State *L) {
530 global_State *g = G(L); 531 global_State *g = G(L);
531 int aux; 532 int aux;
532 lua_assert(g->gray == NULL); 533 /* remark objects cautch by write barrier */
534 propagateall(g);
533 /* remark occasional upvalues of (maybe) dead threads */ 535 /* remark occasional upvalues of (maybe) dead threads */
534 remarkupvals(g); 536 remarkupvals(g);
535 /* remark weak tables */ 537 /* remark weak tables */
@@ -669,10 +671,12 @@ void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
669 global_State *g = G(L); 671 global_State *g = G(L);
670 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); 672 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
671 lua_assert(g->gcgenerational || g->gcstate != GCSfinalize); 673 lua_assert(g->gcgenerational || g->gcstate != GCSfinalize);
672 if (g->gcstate != GCSpropagate) /* sweeping phases? */ 674 lua_assert(ttype(&o->gch) != LUA_TTABLE);
673 black2gray(o); /* just mark as gray to avoid other barriers */ 675 /* must keep invariant? */
674 else /* breaking invariant! */ 676 if (g->gcstate == GCSpropagate || g->gcgenerational)
675 reallymarkobject(g, v); /* restore it */ 677 reallymarkobject(g, v); /* restore invariant */
678 else /* don't mind */
679 makewhite(g, o); /* mark as white just to avoid other barriers */
676} 680}
677 681
678 682