diff options
Diffstat (limited to 'lgc.c')
| -rw-r--r-- | lgc.c | 21 |
1 files changed, 12 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.158 2013/09/03 15:37:10 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.159 2013/09/11 12:26:14 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 | */ |
| @@ -85,9 +85,11 @@ | |||
| 85 | lua_longassert(!(iscollectable(o) && islocal(gcvalue(o)))); \ | 85 | lua_longassert(!(iscollectable(o) && islocal(gcvalue(o)))); \ |
| 86 | marklocalvalue(g,o); } | 86 | marklocalvalue(g,o); } |
| 87 | 87 | ||
| 88 | #define marklocalobject(g,t) \ | ||
| 89 | { if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); } | ||
| 90 | |||
| 88 | #define markobject(g,t) \ | 91 | #define markobject(g,t) \ |
| 89 | { lua_assert((t) == NULL || !islocal(obj2gco(t))); \ | 92 | { lua_assert((t) == NULL || !islocal(obj2gco(t))); marklocalobject(g,t); } |
| 90 | if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); } | ||
| 91 | 93 | ||
| 92 | static void reallymarkobject (global_State *g, GCObject *o); | 94 | static void reallymarkobject (global_State *g, GCObject *o); |
| 93 | 95 | ||
| @@ -291,10 +293,8 @@ static void markmt (global_State *g) { | |||
| 291 | */ | 293 | */ |
| 292 | static void markbeingfnz (global_State *g) { | 294 | static void markbeingfnz (global_State *g) { |
| 293 | GCObject *o; | 295 | GCObject *o; |
| 294 | for (o = g->tobefnz; o != NULL; o = gch(o)->next) { | 296 | for (o = g->tobefnz; o != NULL; o = gch(o)->next) |
| 295 | makewhite(g, o); | 297 | marklocalobject(g, o); |
| 296 | reallymarkobject(g, o); | ||
| 297 | } | ||
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | 300 | ||
| @@ -781,7 +781,7 @@ static GCObject *udata2finalize (global_State *g) { | |||
| 781 | l_setbit(gch(o)->marked, LOCALMARK); | 781 | l_setbit(gch(o)->marked, LOCALMARK); |
| 782 | } | 782 | } |
| 783 | resetbit(gch(o)->marked, FINALIZEDBIT); /* object is back in 'allgc' */ | 783 | resetbit(gch(o)->marked, FINALIZEDBIT); /* object is back in 'allgc' */ |
| 784 | if (!keepinvariant(g)) /* not keeping invariant? */ | 784 | if (issweepphase(g)) |
| 785 | makewhite(g, o); /* "sweep" object */ | 785 | makewhite(g, o); /* "sweep" object */ |
| 786 | return o; | 786 | return o; |
| 787 | } | 787 | } |
| @@ -896,7 +896,7 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { | |||
| 896 | ho->next = *p; /* link it in a "fin" list */ | 896 | ho->next = *p; /* link it in a "fin" list */ |
| 897 | *p = o; | 897 | *p = o; |
| 898 | l_setbit(ho->marked, FINALIZEDBIT); /* mark it as such */ | 898 | l_setbit(ho->marked, FINALIZEDBIT); /* mark it as such */ |
| 899 | if (!keepinvariant(g)) /* not keeping invariant? */ | 899 | if (issweepphase(g)) |
| 900 | makewhite(g, o); /* "sweep" object */ | 900 | makewhite(g, o); /* "sweep" object */ |
| 901 | } | 901 | } |
| 902 | } | 902 | } |
| @@ -1159,6 +1159,9 @@ static lu_mem singlestep (lua_State *L) { | |||
| 1159 | return sweepstep(L, g, GCSsweepall, &g->allgc); | 1159 | return sweepstep(L, g, GCSsweepall, &g->allgc); |
| 1160 | } | 1160 | } |
| 1161 | case GCSsweepall: { | 1161 | case GCSsweepall: { |
| 1162 | return sweepstep(L, g, GCSsweeptobefnz, &g->tobefnz); | ||
| 1163 | } | ||
| 1164 | case GCSsweeptobefnz: { | ||
| 1162 | return sweepstep(L, g, GCSsweepmainth, NULL); | 1165 | return sweepstep(L, g, GCSsweepmainth, NULL); |
| 1163 | } | 1166 | } |
| 1164 | case GCSsweepmainth: { /* sweep main thread */ | 1167 | case GCSsweepmainth: { /* sweep main thread */ |
