diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-12-20 17:40:07 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-12-20 17:40:07 -0200 |
commit | 551b076f1c7f9b66eecd8f6b7a12b1bd7a78b967 (patch) | |
tree | bde2f0e23706683829e87d4e239793de373444e7 /lstate.c | |
parent | 737f119187aca3c8f6743ec6e3cfc04e83723180 (diff) | |
download | lua-551b076f1c7f9b66eecd8f6b7a12b1bd7a78b967.tar.gz lua-551b076f1c7f9b66eecd8f6b7a12b1bd7a78b967.tar.bz2 lua-551b076f1c7f9b66eecd8f6b7a12b1bd7a78b967.zip |
change in the relationship between totalbytes and GCdebt - luaM_realloc_
is too critical to update two counters
Diffstat (limited to 'lstate.c')
-rw-r--r-- | lstate.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.87 2010/11/26 14:32:31 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.88 2010/12/20 18:17:46 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -65,11 +65,14 @@ typedef struct LG { | |||
65 | #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) | 65 | #define fromstate(L) (cast(LX *, cast(lu_byte *, (L)) - offsetof(LX, l))) |
66 | 66 | ||
67 | 67 | ||
68 | |||
69 | /* | 68 | /* |
70 | ** maximum number of nested calls made by error-handling function | 69 | ** set GCdebt to a new value keeping the value (totalbytes + GCdebt) |
70 | ** invariant | ||
71 | */ | 71 | */ |
72 | #define LUAI_EXTRACALLS 10 | 72 | void luaE_setdebt (global_State *g, l_mem debt) { |
73 | g->totalbytes -= (debt - g->GCdebt); | ||
74 | g->GCdebt = debt; | ||
75 | } | ||
73 | 76 | ||
74 | 77 | ||
75 | CallInfo *luaE_extendCI (lua_State *L) { | 78 | CallInfo *luaE_extendCI (lua_State *L) { |
@@ -154,7 +157,6 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
154 | /* pre-create memory-error message */ | 157 | /* pre-create memory-error message */ |
155 | g->memerrmsg = luaS_newliteral(L, MEMERRMSG); | 158 | g->memerrmsg = luaS_newliteral(L, MEMERRMSG); |
156 | luaS_fix(g->memerrmsg); /* it should never be collected */ | 159 | luaS_fix(g->memerrmsg); /* it should never be collected */ |
157 | g->GCdebt = 0; | ||
158 | g->gcrunning = 1; /* allow gc */ | 160 | g->gcrunning = 1; /* allow gc */ |
159 | } | 161 | } |
160 | 162 | ||
@@ -188,7 +190,7 @@ static void close_state (lua_State *L) { | |||
188 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); | 190 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); |
189 | luaZ_freebuffer(L, &g->buff); | 191 | luaZ_freebuffer(L, &g->buff); |
190 | freestack(L); | 192 | freestack(L); |
191 | lua_assert(g->totalbytes == sizeof(LG)); | 193 | lua_assert(gettotalbytes(g) == sizeof(LG)); |
192 | (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); | 194 | (*g->frealloc)(g->ud, fromstate(L), sizeof(LG), 0); |
193 | } | 195 | } |
194 | 196 | ||
@@ -258,6 +260,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
258 | g->gray = g->grayagain = NULL; | 260 | g->gray = g->grayagain = NULL; |
259 | g->weak = g->ephemeron = g->allweak = NULL; | 261 | g->weak = g->ephemeron = g->allweak = NULL; |
260 | g->totalbytes = sizeof(LG); | 262 | g->totalbytes = sizeof(LG); |
263 | g->GCdebt = 0; | ||
261 | g->gcpause = LUAI_GCPAUSE; | 264 | g->gcpause = LUAI_GCPAUSE; |
262 | g->gcmajorinc = LUAI_GCMAJOR; | 265 | g->gcmajorinc = LUAI_GCMAJOR; |
263 | g->gcstepmul = LUAI_GCMUL; | 266 | g->gcstepmul = LUAI_GCMUL; |