From ad0ea7813b39e76b377983138ca995189e22054f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 20 Dec 2023 16:25:20 -0300 Subject: GC parameters encoded as floating-point bytes This encoding brings more precision and a larger range for these parameters. --- lgc.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'lgc.h') diff --git a/lgc.h b/lgc.h index e8dee8a0..6a03f787 100644 --- a/lgc.h +++ b/lgc.h @@ -189,10 +189,12 @@ for each new allocated object.) */ #define LUAI_GCMUL 200 -/* How many objects to allocate before next GC step (log2) */ -#define LUAI_GCSTEPSIZE 8 /* 256 objects */ +/* How many objects to allocate before next GC step */ +#define LUAI_GCSTEPSIZE 250 +#define setgcparam(g,p,v) if ((v) >= 0) {g->p = luaO_codeparam(v);} + /* ** Control when GC is running: */ @@ -201,20 +203,6 @@ #define GCSTPCLS 4 /* bit true when closing Lua state */ #define gcrunning(g) ((g)->gcstp == 0) -/* -** Macros to set and apply GC parameters. GC parameters are given in -** percentage points, but are stored as lu_byte. To avoid repeated -** divisions by 100, these macros store the original parameter -** multiplied by 128 and divided by 100. To apply them, if it first -** divides the value by 128 it may lose precision; if it first -** multiplies by the parameter, it may overflow. So, it first divides -** by 32, then multiply by the parameter, and then divides the result by -** 4. -*/ - -#define setgcparam(g,p,v) (g->gcp##p = (cast_uint(v) << 7) / 100u) -#define applygcparam(g,p,v) ((((v) >> 5) * g->gcp##p) >> 2) - /* ** Does one step of collection when debt becomes zero. 'pre'/'pos' -- cgit v1.2.3-55-g6feb