aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-11 11:47:08 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-11 11:47:08 -0300
commit4eeb1831bee8c424a60b5ca05667b5d1c1bb662e (patch)
treebba7a83b633eae54c67e5797c3559d7faa04f8e1
parentdd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8 (diff)
downloadlua-4eeb1831bee8c424a60b5ca05667b5d1c1bb662e.tar.gz
lua-4eeb1831bee8c424a60b5ca05667b5d1c1bb662e.tar.bz2
lua-4eeb1831bee8c424a60b5ca05667b5d1c1bb662e.zip
new names and better order for GC states (sweep first lists that
can have dead objects)
-rw-r--r--lgc.c30
-rw-r--r--lgc.h18
-rw-r--r--ltests.c12
3 files changed, 30 insertions, 30 deletions
diff --git a/lgc.c b/lgc.c
index 355c1003..be6ca0c1 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.161 2013/09/11 13:24:55 roberto Exp roberto $ 2** $Id: lgc.c,v 2.162 2013/09/11 14:09:55 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*/
@@ -1042,7 +1042,7 @@ static void setpause (global_State *g, l_mem estimate) {
1042static int entersweep (lua_State *L) { 1042static int entersweep (lua_State *L) {
1043 global_State *g = G(L); 1043 global_State *g = G(L);
1044 int n = 0; 1044 int n = 0;
1045 g->gcstate = GCSsweeplocal; 1045 g->gcstate = GCSswplocalgc;
1046 lua_assert(g->sweepgc == NULL); 1046 lua_assert(g->sweepgc == NULL);
1047 g->sweepgc = sweeptolive(L, &g->localgc, &n); 1047 g->sweepgc = sweeptolive(L, &g->localgc, &n);
1048 if (g->sweepgc == NULL) /* no live objects in local list? */ 1048 if (g->sweepgc == NULL) /* no live objects in local list? */
@@ -1151,25 +1151,25 @@ static lu_mem singlestep (lua_State *L) {
1151 sw = entersweep(L); 1151 sw = entersweep(L);
1152 return work + sw * GCSWEEPCOST; 1152 return work + sw * GCSWEEPCOST;
1153 } 1153 }
1154 case GCSsweeplocal: { 1154 case GCSswplocalgc: { /* sweep local objects */
1155 return sweepstep(L, g, GCSsweeplocfin, &g->localfin); 1155 return sweepstep(L, g, GCSswpallgc, &g->allgc);
1156 } 1156 }
1157 case GCSsweeplocfin: { 1157 case GCSswpallgc: { /* sweep non-local objects */
1158 return sweepstep(L, g, GCSsweepfin, &g->finobj); 1158 return sweepstep(L, g, GCSswpthreads, &g->mainthread->next);
1159 } 1159 }
1160 case GCSsweepfin: { 1160 case GCSswpthreads: { /* sweep threads */
1161 return sweepstep(L, g, GCSsweepall, &g->allgc); 1161 return sweepstep(L, g, GCSswplocalfin, &g->localfin);
1162 } 1162 }
1163 case GCSsweepall: { 1163 case GCSswplocalfin: { /* sweep local objects with finalizers */
1164 return sweepstep(L, g, GCSsweeptobefnz, &g->tobefnz); 1164 return sweepstep(L, g, GCSswpfinobj, &g->finobj);
1165 } 1165 }
1166 case GCSsweeptobefnz: { 1166 case GCSswpfinobj: { /* sweep non-local objects with finalizers */
1167 return sweepstep(L, g, GCSsweepthreads, &g->mainthread->next); 1167 return sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
1168 } 1168 }
1169 case GCSsweepthreads: { 1169 case GCSswptobefnz: { /* sweep objects to be finalized */
1170 return sweepstep(L, g, GCSsweepend, NULL); 1170 return sweepstep(L, g, GCSswpend, NULL);
1171 } 1171 }
1172 case GCSsweepend: { 1172 case GCSswpend: { /* finish sweeps */
1173 makewhite(g, obj2gco(g->mainthread)); /* sweep main thread */ 1173 makewhite(g, obj2gco(g->mainthread)); /* sweep main thread */
1174 checkBuffer(L); 1174 checkBuffer(L);
1175 g->gcstate = GCSpause; /* finish collection */ 1175 g->gcstate = GCSpause; /* finish collection */
diff --git a/lgc.h b/lgc.h
index 7a449829..91e241a0 100644
--- a/lgc.h
+++ b/lgc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.h,v 2.73 2013/09/11 12:47:48 roberto Exp roberto $ 2** $Id: lgc.h,v 2.74 2013/09/11 14:09:55 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,18 +38,18 @@
38*/ 38*/
39#define GCSpropagate 0 39#define GCSpropagate 0
40#define GCSatomic 1 40#define GCSatomic 1
41#define GCSsweeplocal 2 41#define GCSswplocalgc 2
42#define GCSsweeplocfin 3 42#define GCSswpallgc 4
43#define GCSsweepfin 4 43#define GCSswpthreads 3
44#define GCSsweepall 5 44#define GCSswplocalfin 5
45#define GCSsweeptobefnz 6 45#define GCSswpfinobj 6
46#define GCSsweepthreads 7 46#define GCSswptobefnz 7
47#define GCSsweepend 8 47#define GCSswpend 8
48#define GCSpause 9 48#define GCSpause 9
49 49
50 50
51#define issweepphase(g) \ 51#define issweepphase(g) \
52 (GCSsweeplocal <= (g)->gcstate && (g)->gcstate <= GCSsweepend) 52 (GCSswplocalgc <= (g)->gcstate && (g)->gcstate <= GCSswpend)
53 53
54 54
55/* 55/*
diff --git a/ltests.c b/ltests.c
index 0f6a23dd..bf32c115 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.157 2013/09/11 12:47:48 roberto Exp roberto $ 2** $Id: ltests.c,v 2.158 2013/09/11 14:09:55 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -434,14 +434,14 @@ int lua_checkmemory (lua_State *L) {
434 markgrays(g); 434 markgrays(g);
435 /* check 'localgc' list */ 435 /* check 'localgc' list */
436 checkgray(g, g->localgc); 436 checkgray(g, g->localgc);
437 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweeplocal); 437 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswplocalgc);
438 for (o = g->localgc; o != NULL; o = gch(o)->next) { 438 for (o = g->localgc; o != NULL; o = gch(o)->next) {
439 checkobject(g, o, maybedead); 439 checkobject(g, o, maybedead);
440 lua_assert(!tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); 440 lua_assert(!tofinalize(o) && !testbit(o->gch.marked, LOCALMARK));
441 } 441 }
442 /* check 'allgc' list */ 442 /* check 'allgc' list */
443 checkgray(g, g->allgc); 443 checkgray(g, g->allgc);
444 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepall); 444 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc);
445 for (o = g->allgc; o != NULL; o = gch(o)->next) { 445 for (o = g->allgc; o != NULL; o = gch(o)->next) {
446 checkobject(g, o, maybedead); 446 checkobject(g, o, maybedead);
447 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); 447 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK));
@@ -449,7 +449,7 @@ int lua_checkmemory (lua_State *L) {
449 } 449 }
450 /* check thread list */ 450 /* check thread list */
451 checkgray(g, obj2gco(g->mainthread)); 451 checkgray(g, obj2gco(g->mainthread));
452 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepthreads); 452 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpthreads);
453 for (o = obj2gco(g->mainthread); o != NULL; o = gch(o)->next) { 453 for (o = obj2gco(g->mainthread); o != NULL; o = gch(o)->next) {
454 checkobject(g, o, maybedead); 454 checkobject(g, o, maybedead);
455 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); 455 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK));
@@ -655,8 +655,8 @@ static int gc_local (lua_State *L) {
655 655
656static int gc_state (lua_State *L) { 656static int gc_state (lua_State *L) {
657 static const char *statenames[] = {"propagate", "atomic", 657 static const char *statenames[] = {"propagate", "atomic",
658 "sweeplocal", "sweeplocfin", "sweepfin", "sweepall", 658 "sweeplocalgc", "sweepallgc", "sweepthreads", "sweeplocalfin",
659 "sweeptobefnz", "sweepthreads", "sweepend", "pause", ""}; 659 "sweepfinobj", "sweeptobefnz", "sweepend", "pause", ""};
660 int option = luaL_checkoption(L, 1, "", statenames); 660 int option = luaL_checkoption(L, 1, "", statenames);
661 if (option == GCSpause + 1) { 661 if (option == GCSpause + 1) {
662 lua_pushstring(L, statenames[G(L)->gcstate]); 662 lua_pushstring(L, statenames[G(L)->gcstate]);