diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 10:24:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-11 10:24:55 -0300 |
commit | 7061fe1d56f40e9d22a226423079da808fb41f66 (patch) | |
tree | 9fcc3d480331bc7cc4548ff2c184c813e606156e | |
parent | d8aa8dd97e14dfd724e997261d305f2045d1ca63 (diff) | |
download | lua-7061fe1d56f40e9d22a226423079da808fb41f66.tar.gz lua-7061fe1d56f40e9d22a226423079da808fb41f66.tar.bz2 lua-7061fe1d56f40e9d22a226423079da808fb41f66.zip |
detail: 'sweepstep' checks end of phase after calling 'sweeplist', so
that phases with small lists return 0 at the first call to 'sweepstep'
-rw-r--r-- | lgc.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.159 2013/09/11 12:26:14 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.160 2013/09/11 12:47:48 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 | */ |
@@ -740,7 +740,7 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { | |||
740 | ** sweep a list until a live object (or end of list) | 740 | ** sweep a list until a live object (or end of list) |
741 | */ | 741 | */ |
742 | static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { | 742 | static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) { |
743 | GCObject ** old = p; | 743 | GCObject **old = p; |
744 | int i = 0; | 744 | int i = 0; |
745 | do { | 745 | do { |
746 | i++; | 746 | i++; |
@@ -1046,6 +1046,8 @@ static int entersweep (lua_State *L) { | |||
1046 | g->gcstate = GCSsweeplocal; | 1046 | g->gcstate = GCSsweeplocal; |
1047 | lua_assert(g->sweepgc == NULL); | 1047 | lua_assert(g->sweepgc == NULL); |
1048 | g->sweepgc = sweeptolive(L, &g->localgc, &n); | 1048 | g->sweepgc = sweeptolive(L, &g->localgc, &n); |
1049 | if (g->sweepgc == NULL) /* no live objects in local list? */ | ||
1050 | g->sweepgc = &g->localgc; /* 'sweepgc' cannot be NULL here */ | ||
1049 | return n; | 1051 | return n; |
1050 | } | 1052 | } |
1051 | 1053 | ||
@@ -1109,11 +1111,10 @@ static l_mem atomic (lua_State *L) { | |||
1109 | 1111 | ||
1110 | static lu_mem sweepstep (lua_State *L, global_State *g, | 1112 | static lu_mem sweepstep (lua_State *L, global_State *g, |
1111 | int nextstate, GCObject **nextlist) { | 1113 | int nextstate, GCObject **nextlist) { |
1112 | if (g->sweepgc) { /* is there still something to sweep? */ | 1114 | g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); |
1113 | g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); | 1115 | if (g->sweepgc) /* is there still something to sweep? */ |
1114 | return (GCSWEEPMAX * GCSWEEPCOST); | 1116 | return (GCSWEEPMAX * GCSWEEPCOST); |
1115 | } | 1117 | else { /* enter next state */ |
1116 | else { /* next phase */ | ||
1117 | g->gcstate = nextstate; | 1118 | g->gcstate = nextstate; |
1118 | g->sweepgc = nextlist; | 1119 | g->sweepgc = nextlist; |
1119 | return 0; | 1120 | return 0; |