commit 1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797
parent bed2cb725a6601de2c0b0e7e5db90d23a7435460
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 28 Sep 2009 10:50:10 -0300
some operations may shrink g->totalbytes so g->estimate must be
more flexible
Diffstat:
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lgc.c b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.54 2009/06/08 19:35:59 roberto Exp roberto $
+** $Id: lgc.c,v 2.55 2009/07/16 16:26:09 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -735,12 +735,16 @@ static void atomic (lua_State *L) {
g->currentwhite = cast_byte(otherwhite(g));
g->sweepstrgc = 0;
g->gcstate = GCSsweepstring;
+ lua_assert(g->totalbytes > udsize);
g->estimate = g->totalbytes - udsize; /* first estimate */
}
-#define correctestimate(g,s) {lu_mem old = g->totalbytes; s; \
- lua_assert(old >= g->totalbytes); g->estimate -= old - g->totalbytes;}
+#define correctestimate(g,s) { \
+ lu_mem old = g->totalbytes; s; \
+ lua_assert(old >= g->totalbytes); \
+ if (g->estimate >= old - g->totalbytes) \
+ g->estimate -= (old - g->totalbytes);}
static l_mem singlestep (lua_State *L) {
@@ -813,7 +817,8 @@ void luaC_step (lua_State *L) {
}
}
else {
- lua_assert(g->totalbytes >= g->estimate);
+ if (g->estimate > g->totalbytes)
+ g->estimate = g->totalbytes;
setthreshold(g);
}
}