diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-18 13:59:09 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-18 13:59:09 -0200 |
commit | f2c451d7455aad3496f32dfa2bfca7f7e8b5376d (patch) | |
tree | 38e30f839516ff5b6178351750b5e3256f4dd98e /lgc.c | |
parent | 619edfd9e4c210bdfcfbf1e911d1760c53c4293f (diff) | |
download | lua-f2c451d7455aad3496f32dfa2bfca7f7e8b5376d.tar.gz lua-f2c451d7455aad3496f32dfa2bfca7f7e8b5376d.tar.bz2 lua-f2c451d7455aad3496f32dfa2bfca7f7e8b5376d.zip |
all accesses to TObjects done through macros
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.74 2000/12/26 18:46:09 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.75 2000/12/28 12:55:41 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 | */ |
@@ -145,7 +145,7 @@ static void markall (lua_State *L) { | |||
145 | 145 | ||
146 | static int hasmark (const TObject *o) { | 146 | static int hasmark (const TObject *o) { |
147 | /* valid only for locked objects */ | 147 | /* valid only for locked objects */ |
148 | switch (o->ttype) { | 148 | switch (ttype(o)) { |
149 | case LUA_TSTRING: case LUA_TUSERDATA: | 149 | case LUA_TSTRING: case LUA_TUSERDATA: |
150 | return tsvalue(o)->marked; | 150 | return tsvalue(o)->marked; |
151 | case LUA_TTABLE: | 151 | case LUA_TTABLE: |
@@ -290,15 +290,14 @@ static void checkMbuffer (lua_State *L) { | |||
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | static void callgcTM (lua_State *L, const TObject *o) { | 293 | static void callgcTM (lua_State *L, const TObject *obj) { |
294 | Closure *tm = luaT_gettmbyObj(L, o, TM_GC); | 294 | Closure *tm = luaT_gettmbyObj(L, obj, TM_GC); |
295 | if (tm != NULL) { | 295 | if (tm != NULL) { |
296 | int oldah = L->allowhooks; | 296 | int oldah = L->allowhooks; |
297 | L->allowhooks = 0; /* stop debug hooks during GC tag methods */ | 297 | L->allowhooks = 0; /* stop debug hooks during GC tag methods */ |
298 | luaD_checkstack(L, 2); | 298 | luaD_checkstack(L, 2); |
299 | clvalue(L->top) = tm; | 299 | setclvalue(L->top, tm); |
300 | ttype(L->top) = LUA_TFUNCTION; | 300 | setobj(L->top+1, obj); |
301 | *(L->top+1) = *o; | ||
302 | L->top += 2; | 301 | L->top += 2; |
303 | luaD_call(L, L->top-2, 0); | 302 | luaD_call(L, L->top-2, 0); |
304 | L->allowhooks = oldah; /* restore hooks */ | 303 | L->allowhooks = oldah; /* restore hooks */ |
@@ -308,15 +307,14 @@ static void callgcTM (lua_State *L, const TObject *o) { | |||
308 | 307 | ||
309 | static void callgcTMudata (lua_State *L) { | 308 | static void callgcTMudata (lua_State *L) { |
310 | int tag; | 309 | int tag; |
311 | TObject o; | ||
312 | ttype(&o) = LUA_TUSERDATA; | ||
313 | L->GCthreshold = 2*L->nblocks; /* avoid GC during tag methods */ | 310 | L->GCthreshold = 2*L->nblocks; /* avoid GC during tag methods */ |
314 | for (tag=L->ntag-1; tag>=0; tag--) { /* for each tag (in reverse order) */ | 311 | for (tag=L->ntag-1; tag>=0; tag--) { /* for each tag (in reverse order) */ |
315 | TString *udata; | 312 | TString *udata; |
316 | while ((udata = L->TMtable[tag].collected) != NULL) { | 313 | while ((udata = L->TMtable[tag].collected) != NULL) { |
314 | TObject obj; | ||
317 | L->TMtable[tag].collected = udata->nexthash; /* remove it from list */ | 315 | L->TMtable[tag].collected = udata->nexthash; /* remove it from list */ |
318 | tsvalue(&o) = udata; | 316 | setuvalue(&obj, udata); |
319 | callgcTM(L, &o); | 317 | callgcTM(L, &obj); |
320 | luaM_free(L, udata, sizeudata(udata->len)); | 318 | luaM_free(L, udata, sizeudata(udata->len)); |
321 | } | 319 | } |
322 | } | 320 | } |