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. --- lapi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index 34e64af1..3c620d4b 100644 --- a/lapi.c +++ b/lapi.c @@ -1154,11 +1154,11 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { } case LUA_GCCOUNT: { /* GC values are expressed in Kbytes: #bytes/2^10 */ - res = cast_int(gettotalbytes(g) >> 10); + res = cast_int(g->totalbytes >> 10); break; } case LUA_GCCOUNTB: { - res = cast_int(gettotalbytes(g) & 0x3ff); + res = cast_int(g->totalbytes & 0x3ff); break; } case LUA_GCSTEP: { @@ -1171,7 +1171,7 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { luaC_step(L); } else { /* add 'data' to total debt */ - debt = cast(l_mem, data) * 1024 + g->GCdebt; + debt = data + g->GCdebt; luaE_setdebt(g, debt); luaC_checkGC(L); } @@ -1217,7 +1217,8 @@ LUA_API int lua_gc (lua_State *L, int what, ...) { if (stepmul != 0) setgcparam(g->gcstepmul, stepmul); if (stepsize != 0) - g->gcstepsize = stepsize; + g->gcstepsize = (stepsize <= log2maxs(l_mem)) ? stepsize + : log2maxs(l_mem); luaC_changemode(L, KGC_INC); break; } -- cgit v1.2.3-55-g6feb