aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lgc.c b/lgc.c
index f09af8e7..f905d9d5 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.152 2013/08/26 12:41:10 roberto Exp roberto $ 2** $Id: lgc.c,v 2.153 2013/08/27 18:53:35 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*/
@@ -208,9 +208,11 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list,
208 global_State *g = G(L); 208 global_State *g = G(L);
209 char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz)); 209 char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz));
210 GCObject *o = obj2gco(raw + offset); 210 GCObject *o = obj2gco(raw + offset);
211 if (list == NULL)
212 list = &g->allgc; /* standard list for collectable objects */
213 gch(o)->marked = luaC_white(g); 211 gch(o)->marked = luaC_white(g);
212 if (list == NULL)
213 list = &g->localgc; /* standard list for collectable objects */
214 else
215 l_setbit(gch(o)->marked, LOCALMARK); /* mark object as not in 'localgc' */
214 gch(o)->tt = tt; 216 gch(o)->tt = tt;
215 gch(o)->next = *list; 217 gch(o)->next = *list;
216 *list = o; 218 *list = o;
@@ -894,7 +896,7 @@ static void localmarkthread (lua_State *l) {
894 return; /* stack not completely built yet */ 896 return; /* stack not completely built yet */
895 for (; o < l->top; o++) { /* mark live elements in the stack */ 897 for (; o < l->top; o++) { /* mark live elements in the stack */
896 if (iscollectable(o)) 898 if (iscollectable(o))
897 l_setbit(gcvalue(o)->gch.marked, LOCALBLACK); 899 l_setbit(gcvalue(o)->gch.marked, LOCALMARK);
898 } 900 }
899} 901}
900 902
@@ -918,10 +920,12 @@ static void localsweep (lua_State *L, global_State *g, GCObject **p) {
918 *p = curr->gch.next; /* remove 'curr' from list */ 920 *p = curr->gch.next; /* remove 'curr' from list */
919 curr->gch.next = g->allgc; /* link 'curr' in 'allgc' list */ 921 curr->gch.next = g->allgc; /* link 'curr' in 'allgc' list */
920 g->allgc = curr; 922 g->allgc = curr;
923 /* mark it as out of local list */
924 l_setbit(curr->gch.marked, LOCALMARK);
921 } 925 }
922 else { /* still local */ 926 else { /* still local */
923 if (testbit(curr->gch.marked, LOCALBLACK)) { /* locally alive? */ 927 if (testbit(curr->gch.marked, LOCALMARK)) { /* locally alive? */
924 resetbit(curr->gch.marked, LOCALBLACK); 928 resetbit(curr->gch.marked, LOCALMARK);
925 p = &curr->gch.next; /* go to next element */ 929 p = &curr->gch.next; /* go to next element */
926 } 930 }
927 else { /* object is dead */ 931 else { /* object is dead */