From aaa5d7adab1fd4a2f2d0c1f2996e354445ad163f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 29 Apr 2010 14:32:40 -0300 Subject: 'luaC_linkupval' moved into 'lfunc.c' code + new way to control GC speed --- lgc.h | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lgc.h') diff --git a/lgc.h b/lgc.h index 38564849..b7e00b38 100644 --- a/lgc.h +++ b/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.29 2010/03/24 15:51:10 roberto Exp roberto $ +** $Id: lgc.h,v 2.30 2010/03/25 13:06:36 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -23,6 +23,24 @@ #define GCSfinalize 6 +#define issweepphase(g) \ + (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep) + + +/* +** macro to tell when main invariant (white objects cannot point to black +** ones) must be kept. During a non-generational collection, the sweep +** phase may brak the invariant, as objects turned white may point to +** still-black objects. The invariant is restored when sweep ends and +** all objects are white again. During a generational collection, the +** invariant must be kept all times. +*/ +#define keepinvariant(g) (g->gckind == KGC_GEN || g->gcstate == GCSpropagate) + + +#define gcstopped(g) ((g)->GCdebt == MIN_LMEM) +#define stopgc(g) ((g)->GCdebt = MIN_LMEM) + /* ** some useful bit tricks @@ -76,8 +94,7 @@ #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) -#define luaC_checkGC(L) \ - {condchangemem(L); if (G(L)->totalbytes >= G(L)->GCthreshold) luaC_step(L);} +#define luaC_checkGC(L) {condchangemem(L); if (G(L)->GCdebt > 0) luaC_step(L);} #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ @@ -100,7 +117,6 @@ LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, GCObject **list, int offset); -LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); -- cgit v1.2.3-55-g6feb