diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-04-14 15:12:35 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-04-14 15:12:35 -0300 |
commit | 870f61d2998cc9a998b9599997ae8975879d9314 (patch) | |
tree | e87398ff6bcf367357d7e6813332568247136a9c | |
parent | c845ec777a29e434da6ceee50de9d5a6dfa40ea7 (diff) | |
download | lua-870f61d2998cc9a998b9599997ae8975879d9314.tar.gz lua-870f61d2998cc9a998b9599997ae8975879d9314.tar.bz2 lua-870f61d2998cc9a998b9599997ae8975879d9314.zip |
code redistribution
-rw-r--r-- | ldo.c | 13 | ||||
-rw-r--r-- | ldo.h | 3 | ||||
-rw-r--r-- | lgc.c | 17 |
3 files changed, 16 insertions, 17 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.71 2000/03/30 17:19:48 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.72 2000/03/30 20:55:50 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -326,17 +326,6 @@ static int do_main (lua_State *L, ZIO *z, int bin) { | |||
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | void luaD_gcIM (lua_State *L, const TObject *o) { | ||
330 | const TObject *im = luaT_getimbyObj(L, o, IM_GC); | ||
331 | if (ttype(im) != TAG_NIL) { | ||
332 | luaD_checkstack(L, 2); | ||
333 | *(L->top++) = *im; | ||
334 | *(L->top++) = *o; | ||
335 | luaD_call(L, L->top-2, 0); | ||
336 | } | ||
337 | } | ||
338 | |||
339 | |||
340 | #define MAXFILENAME 260 /* maximum part of a file name kept */ | 329 | #define MAXFILENAME 260 /* maximum part of a file name kept */ |
341 | 330 | ||
342 | int lua_dofile (lua_State *L, const char *filename) { | 331 | int lua_dofile (lua_State *L, const char *filename) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.h,v 1.18 2000/03/24 17:26:08 roberto Exp roberto $ | 2 | ** $Id: ldo.h,v 1.19 2000/03/29 20:19:20 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -26,7 +26,6 @@ void luaD_lineHook (lua_State *L, StkId func, int line); | |||
26 | void luaD_call (lua_State *L, StkId func, int nResults); | 26 | void luaD_call (lua_State *L, StkId func, int nResults); |
27 | void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults); | 27 | void luaD_callTM (lua_State *L, const TObject *f, int nParams, int nResults); |
28 | int luaD_protectedrun (lua_State *L); | 28 | int luaD_protectedrun (lua_State *L); |
29 | void luaD_gcIM (lua_State *L, const TObject *o); | ||
30 | void luaD_checkstack (lua_State *L, int n); | 29 | void luaD_checkstack (lua_State *L, int n); |
31 | 30 | ||
32 | 31 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.45 2000/03/29 20:19:20 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.46 2000/03/30 20:55:50 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 | */ |
@@ -20,6 +20,17 @@ | |||
20 | 20 | ||
21 | 21 | ||
22 | 22 | ||
23 | static void luaD_gcTM (lua_State *L, const TObject *o) { | ||
24 | const TObject *im = luaT_getimbyObj(L, o, IM_GC); | ||
25 | if (ttype(im) != TAG_NIL) { | ||
26 | luaD_checkstack(L, 2); | ||
27 | *(L->top++) = *im; | ||
28 | *(L->top++) = *o; | ||
29 | luaD_call(L, L->top-2, 0); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | |||
23 | static int markobject (lua_State *L, TObject *o); | 34 | static int markobject (lua_State *L, TObject *o); |
24 | 35 | ||
25 | 36 | ||
@@ -201,7 +212,7 @@ static void collectstring (lua_State *L, int limit) { | |||
201 | else { /* collect */ | 212 | else { /* collect */ |
202 | if (next->constindex == -1) { /* is userdata? */ | 213 | if (next->constindex == -1) { /* is userdata? */ |
203 | tsvalue(&o) = next; | 214 | tsvalue(&o) = next; |
204 | luaD_gcIM(L, &o); | 215 | luaD_gcTM(L, &o); |
205 | } | 216 | } |
206 | *p = next->nexthash; | 217 | *p = next->nexthash; |
207 | luaS_free(L, next); | 218 | luaS_free(L, next); |
@@ -240,13 +251,13 @@ long lua_collectgarbage (lua_State *L, long limit) { | |||
240 | markall(L); | 251 | markall(L); |
241 | luaR_invalidaterefs(L); | 252 | luaR_invalidaterefs(L); |
242 | luaC_collect(L, 0); | 253 | luaC_collect(L, 0); |
243 | luaD_gcIM(L, &luaO_nilobject); /* GC tag method for nil (signal end of GC) */ | ||
244 | recovered = recovered - L->nblocks; | 254 | recovered = recovered - L->nblocks; |
245 | L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit; | 255 | L->GCthreshold = (limit == 0) ? 2*L->nblocks : L->nblocks+limit; |
246 | if (L->Mbuffsize > L->Mbuffnext*4) { /* is buffer too big? */ | 256 | if (L->Mbuffsize > L->Mbuffnext*4) { /* is buffer too big? */ |
247 | L->Mbuffsize /= 2; /* still larger than Mbuffnext*2 */ | 257 | L->Mbuffsize /= 2; /* still larger than Mbuffnext*2 */ |
248 | luaM_reallocvector(L, L->Mbuffer, L->Mbuffsize, char); | 258 | luaM_reallocvector(L, L->Mbuffer, L->Mbuffsize, char); |
249 | } | 259 | } |
260 | luaD_gcTM(L, &luaO_nilobject); | ||
250 | return recovered; | 261 | return recovered; |
251 | } | 262 | } |
252 | 263 | ||