diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-09-15 17:38:15 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-09-15 17:38:15 -0300 |
| commit | 0e54d2be365ec77cb455e0d0f3c5c6f9efa6e04c (patch) | |
| tree | 10c2fa2a836c29a17bbe0a5085f898ac591eeee6 | |
| parent | 226c57fec0cc2a1b9457ec4204f13c5b7a108cc7 (diff) | |
| download | lua-0e54d2be365ec77cb455e0d0f3c5c6f9efa6e04c.tar.gz lua-0e54d2be365ec77cb455e0d0f3c5c6f9efa6e04c.tar.bz2 lua-0e54d2be365ec77cb455e0d0f3c5c6f9efa6e04c.zip | |
bug: barrier was wrong for generational phase
| -rw-r--r-- | lgc.c | 18 | ||||
| -rw-r--r-- | lgc.h | 6 |
2 files changed, 16 insertions, 8 deletions
| @@ -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 */ |
| 500 | static void markroot (lua_State *L) { | 500 | static 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) { | |||
| 513 | static void remarkupvals (global_State *g) { | 513 | static 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) { | |||
| 529 | static void atomic (lua_State *L) { | 530 | static 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 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.h,v 2.7 2004/08/24 20:12:06 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.8 2004/08/30 13:44:44 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 | */ |
| @@ -86,6 +86,10 @@ | |||
| 86 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ | 86 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ |
| 87 | luaC_barrierf(L,obj2gco(p),obj2gco(o)); } | 87 | luaC_barrierf(L,obj2gco(p),obj2gco(o)); } |
| 88 | 88 | ||
| 89 | #define luaC_objbarriert(L,p,o) \ | ||
| 90 | { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \ | ||
| 91 | luaC_barrierback(L,obj2gco(p),obj2gco(o)); } | ||
| 92 | |||
| 89 | size_t luaC_separateudata (lua_State *L, int all); | 93 | size_t luaC_separateudata (lua_State *L, int all); |
| 90 | void luaC_callGCTM (lua_State *L); | 94 | void luaC_callGCTM (lua_State *L); |
| 91 | void luaC_freeall (lua_State *L); | 95 | void luaC_freeall (lua_State *L); |
