lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 1ec251e091302515e54aa81d965840a5de4be0a1
parent 5894ca7b95d7fb05f1e93ee77e849a8d816d1c6d
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon,  6 Jan 2025 12:41:12 -0300

Detail (debugging aid)

When compiling with option HARDMEMTESTS, every creation of a new key
in a table forces an emergency GC.

Diffstat:
Mlgc.h | 8++++----
Mltable.c | 2++
2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/lgc.h b/lgc.h @@ -224,15 +224,15 @@ */ #if !defined(HARDMEMTESTS) -#define condchangemem(L,pre,pos) ((void)0) +#define condchangemem(L,pre,pos,emg) ((void)0) #else -#define condchangemem(L,pre,pos) \ - { if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } +#define condchangemem(L,pre,pos,emg) \ + { if (gcrunning(G(L))) { pre; luaC_fullgc(L, emg); pos; } } #endif #define luaC_condGC(L,pre,pos) \ { if (G(L)->GCdebt <= 0) { pre; luaC_step(L); pos;}; \ - condchangemem(L,pre,pos); } + condchangemem(L,pre,pos,0); } /* more often than not, 'pre'/'pos' are empty */ #define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) diff --git a/ltable.c b/ltable.c @@ -910,6 +910,8 @@ static void luaH_newkey (lua_State *L, Table *t, const TValue *key, newcheckedkey(t, key, value); /* insert key in grown table */ } luaC_barrierback(L, obj2gco(t), key); + /* for debugging only: any new key may force an emergency collection */ + condchangemem(L, (void)0, (void)0, 1); } }