detail: 'sweepstep' checks end of phase after calling 'sweeplist', so
that phases with small lists return 0 at the first call to 'sweepstep'
This commit is contained in:
13
lgc.c
13
lgc.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 2.159 2013/09/11 12:26:14 roberto Exp roberto $
|
** $Id: lgc.c,v 2.160 2013/09/11 12:47:48 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -740,7 +740,7 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
|
|||||||
** sweep a list until a live object (or end of list)
|
** sweep a list until a live object (or end of list)
|
||||||
*/
|
*/
|
||||||
static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
|
static GCObject **sweeptolive (lua_State *L, GCObject **p, int *n) {
|
||||||
GCObject ** old = p;
|
GCObject **old = p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
i++;
|
i++;
|
||||||
@@ -1046,6 +1046,8 @@ static int entersweep (lua_State *L) {
|
|||||||
g->gcstate = GCSsweeplocal;
|
g->gcstate = GCSsweeplocal;
|
||||||
lua_assert(g->sweepgc == NULL);
|
lua_assert(g->sweepgc == NULL);
|
||||||
g->sweepgc = sweeptolive(L, &g->localgc, &n);
|
g->sweepgc = sweeptolive(L, &g->localgc, &n);
|
||||||
|
if (g->sweepgc == NULL) /* no live objects in local list? */
|
||||||
|
g->sweepgc = &g->localgc; /* 'sweepgc' cannot be NULL here */
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1109,11 +1111,10 @@ static l_mem atomic (lua_State *L) {
|
|||||||
|
|
||||||
static lu_mem sweepstep (lua_State *L, global_State *g,
|
static lu_mem sweepstep (lua_State *L, global_State *g,
|
||||||
int nextstate, GCObject **nextlist) {
|
int nextstate, GCObject **nextlist) {
|
||||||
if (g->sweepgc) { /* is there still something to sweep? */
|
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
|
||||||
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
|
if (g->sweepgc) /* is there still something to sweep? */
|
||||||
return (GCSWEEPMAX * GCSWEEPCOST);
|
return (GCSWEEPMAX * GCSWEEPCOST);
|
||||||
}
|
else { /* enter next state */
|
||||||
else { /* next phase */
|
|
||||||
g->gcstate = nextstate;
|
g->gcstate = nextstate;
|
||||||
g->sweepgc = nextlist;
|
g->sweepgc = nextlist;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user