diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-11-23 17:17:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-11-23 17:17:20 -0300 |
commit | f356d5acdd9d8e8f7e9d1d7632c4657f945ff4f4 (patch) | |
tree | baa2abdc9bd4707b42c0609da42aa1130757273b /lstate.h | |
parent | 76953316d1283ab6324b59b914ef53a521408444 (diff) | |
download | lua-f356d5acdd9d8e8f7e9d1d7632c4657f945ff4f4.tar.gz lua-f356d5acdd9d8e8f7e9d1d7632c4657f945ff4f4.tar.bz2 lua-f356d5acdd9d8e8f7e9d1d7632c4657f945ff4f4.zip |
First version of GC counting objects for control
Still needs to review generational mode.
Diffstat (limited to 'lstate.h')
-rw-r--r-- | lstate.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -249,9 +249,10 @@ typedef struct CallInfo { | |||
249 | typedef struct global_State { | 249 | typedef struct global_State { |
250 | lua_Alloc frealloc; /* function to reallocate memory */ | 250 | lua_Alloc frealloc; /* function to reallocate memory */ |
251 | void *ud; /* auxiliary data to 'frealloc' */ | 251 | void *ud; /* auxiliary data to 'frealloc' */ |
252 | l_mem totalbytes; /* number of bytes currently allocated - GCdebt */ | 252 | l_mem totalbytes; /* number of bytes currently allocated */ |
253 | l_mem totalobjs; /* total number of objects allocated */ | 253 | l_mem totalobjs; /* total number of objects allocated - GCdebt */ |
254 | l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ | 254 | l_mem GCdebt; /* bytes allocated not yet compensated by the collector */ |
255 | lu_mem marked; /* number of objects marked in a GC cycle */ | ||
255 | lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ | 256 | lu_mem GCestimate; /* an estimate of the non-garbage memory in use */ |
256 | lu_mem lastatomic; /* see function 'genstep' in file 'lgc.c' */ | 257 | lu_mem lastatomic; /* see function 'genstep' in file 'lgc.c' */ |
257 | stringtable strt; /* hash table for strings */ | 258 | stringtable strt; /* hash table for strings */ |
@@ -386,8 +387,9 @@ union GCUnion { | |||
386 | #define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc)) | 387 | #define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc)) |
387 | 388 | ||
388 | 389 | ||
389 | /* actual number of total bytes allocated */ | 390 | /* actual number of total objects allocated */ |
390 | #define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt) | 391 | #define gettotalobjs(g) ((g)->totalobjs + (g)->GCdebt) |
392 | |||
391 | 393 | ||
392 | LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); | 394 | LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); |
393 | LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); | 395 | LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); |