From f356d5acdd9d8e8f7e9d1d7632c4657f945ff4f4 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 23 Nov 2022 17:17:20 -0300 Subject: First version of GC counting objects for control Still needs to review generational mode. --- lstate.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index 62ad61c6..3ffd09b7 100644 --- a/lstate.h +++ b/lstate.h @@ -249,9 +249,10 @@ typedef struct CallInfo { typedef struct global_State { lua_Alloc frealloc; /* function to reallocate memory */ void *ud; /* auxiliary data to 'frealloc' */ - l_mem totalbytes; /* number of bytes currently allocated - GCdebt */ - l_mem totalobjs; /* total number of objects allocated */ + l_mem totalbytes; /* number of bytes currently allocated */ + l_mem totalobjs; /* total number of objects allocated - GCdebt */ l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ + lu_mem marked; /* number of objects marked in a GC cycle */ lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ lu_mem lastatomic; /* see function 'genstep' in file 'lgc.c' */ stringtable strt; /* hash table for strings */ @@ -386,8 +387,9 @@ union GCUnion { #define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc)) -/* actual number of total bytes allocated */ -#define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt) +/* actual number of total objects allocated */ +#define gettotalobjs(g) ((g)->totalobjs + (g)->GCdebt) + LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); -- cgit v1.2.3-55-g6feb