1
0
mirror of https://github.com/lua/lua.git synced 2025-02-04 06:13:04 +08:00

Detail (debugging aid)

When compiling with option HARDMEMTESTS, every creation of a new key
in a table forces an emergency GC.
This commit is contained in:
Roberto Ierusalimschy 2025-01-06 12:41:39 -03:00
parent 5894ca7b95
commit 1ec251e091
2 changed files with 6 additions and 4 deletions

8
lgc.h
View File

@ -224,15 +224,15 @@
*/ */
#if !defined(HARDMEMTESTS) #if !defined(HARDMEMTESTS)
#define condchangemem(L,pre,pos) ((void)0) #define condchangemem(L,pre,pos,emg) ((void)0)
#else #else
#define condchangemem(L,pre,pos) \ #define condchangemem(L,pre,pos,emg) \
{ if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } { if (gcrunning(G(L))) { pre; luaC_fullgc(L, emg); pos; } }
#endif #endif
#define luaC_condGC(L,pre,pos) \ #define luaC_condGC(L,pre,pos) \
{ if (G(L)->GCdebt <= 0) { pre; luaC_step(L); 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 */ /* more often than not, 'pre'/'pos' are empty */
#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) #define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0)

View File

@ -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 */ newcheckedkey(t, key, value); /* insert key in grown table */
} }
luaC_barrierback(L, obj2gco(t), key); luaC_barrierback(L, obj2gco(t), key);
/* for debugging only: any new key may force an emergency collection */
condchangemem(L, (void)0, (void)0, 1);
} }
} }