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. --- ltests.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 51e4ff9b..93af528e 100644 --- a/ltests.c +++ b/ltests.c @@ -1033,16 +1033,35 @@ static int table_query (lua_State *L) { } -static int query_inc (lua_State *L) { +static int query_GCparams (lua_State *L) { global_State *g = G(L); lua_pushinteger(L, gettotalobjs(g)); lua_pushinteger(L, g->GCdebt); - lua_pushinteger(L, applygcparam(g, gcpause, 100)); - lua_pushinteger(L, applygcparam(g, gcstepmul, 100)); - lua_pushinteger(L, cast(l_obj, 1) << g->gcstepsize); - return 5; + lua_pushinteger(L, luaO_applyparam(g->gcpgenminormul, 100)); + lua_pushinteger(L, luaO_applyparam(g->gcpmajorminor, 100)); + lua_pushinteger(L, luaO_applyparam(g->gcpminormajor, 100)); + lua_pushinteger(L, luaO_applyparam(g->gcppause, 100)); + lua_pushinteger(L, luaO_applyparam(g->gcpstepmul, 100)); + lua_pushinteger(L, luaO_applyparam(g->gcpstepsize, 100)); + return 8; +} + + +static int test_codeparam (lua_State *L) { + lua_Integer p = luaL_checkinteger(L, 1); + lua_pushinteger(L, luaO_codeparam(p)); + return 1; } + +static int test_applyparam (lua_State *L) { + lua_Integer p = luaL_checkinteger(L, 1); + lua_Integer x = luaL_checkinteger(L, 2); + lua_pushinteger(L, luaO_applyparam(p, x)); + return 1; +} + + static int string_query (lua_State *L) { stringtable *tb = &G(L)->strt; int s = cast_int(luaL_optinteger(L, 1, 0)) - 1; @@ -1974,7 +1993,9 @@ static const struct luaL_Reg tests_funcs[] = { {"pushuserdata", pushuserdata}, {"querystr", string_query}, {"querytab", table_query}, - {"queryinc", query_inc}, + {"queryGCparams", query_GCparams}, + {"codeparam", test_codeparam}, + {"applyparam", test_applyparam}, {"ref", tref}, {"resume", coresume}, {"s2d", s2d}, -- cgit v1.2.3-55-g6feb