diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-28 10:50:34 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-09-28 10:50:34 -0300 |
commit | 1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797 (patch) | |
tree | 53836f1c8e269de3349e3838dc302b2109a1de9e | |
parent | bed2cb725a6601de2c0b0e7e5db90d23a7435460 (diff) | |
download | lua-1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797.tar.gz lua-1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797.tar.bz2 lua-1829911d7c1c16cf01dfdbfc8e7a26cfa10ec797.zip |
some operations may shrink g->totalbytes so g->estimate must be
more flexible
-rw-r--r-- | lgc.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.54 2009/06/08 19:35:59 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.55 2009/07/16 16:26:09 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 | */ |
@@ -735,12 +735,16 @@ static void atomic (lua_State *L) { | |||
735 | g->currentwhite = cast_byte(otherwhite(g)); | 735 | g->currentwhite = cast_byte(otherwhite(g)); |
736 | g->sweepstrgc = 0; | 736 | g->sweepstrgc = 0; |
737 | g->gcstate = GCSsweepstring; | 737 | g->gcstate = GCSsweepstring; |
738 | lua_assert(g->totalbytes > udsize); | ||
738 | g->estimate = g->totalbytes - udsize; /* first estimate */ | 739 | g->estimate = g->totalbytes - udsize; /* first estimate */ |
739 | } | 740 | } |
740 | 741 | ||
741 | 742 | ||
742 | #define correctestimate(g,s) {lu_mem old = g->totalbytes; s; \ | 743 | #define correctestimate(g,s) { \ |
743 | lua_assert(old >= g->totalbytes); g->estimate -= old - g->totalbytes;} | 744 | lu_mem old = g->totalbytes; s; \ |
745 | lua_assert(old >= g->totalbytes); \ | ||
746 | if (g->estimate >= old - g->totalbytes) \ | ||
747 | g->estimate -= (old - g->totalbytes);} | ||
744 | 748 | ||
745 | 749 | ||
746 | static l_mem singlestep (lua_State *L) { | 750 | static l_mem singlestep (lua_State *L) { |
@@ -813,7 +817,8 @@ void luaC_step (lua_State *L) { | |||
813 | } | 817 | } |
814 | } | 818 | } |
815 | else { | 819 | else { |
816 | lua_assert(g->totalbytes >= g->estimate); | 820 | if (g->estimate > g->totalbytes) |
821 | g->estimate = g->totalbytes; | ||
817 | setthreshold(g); | 822 | setthreshold(g); |
818 | } | 823 | } |
819 | } | 824 | } |