aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-06 12:41:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-01-06 12:41:39 -0300
commit1ec251e091302515e54aa81d965840a5de4be0a1 (patch)
tree6383ca33c3ad46984b341c5c393fac9947d03bfd
parent5894ca7b95d7fb05f1e93ee77e849a8d816d1c6d (diff)
downloadlua-1ec251e091302515e54aa81d965840a5de4be0a1.tar.gz
lua-1ec251e091302515e54aa81d965840a5de4be0a1.tar.bz2
lua-1ec251e091302515e54aa81d965840a5de4be0a1.zip
Detail (debugging aid)
When compiling with option HARDMEMTESTS, every creation of a new key in a table forces an emergency GC.
-rw-r--r--lgc.h8
-rw-r--r--ltable.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/lgc.h b/lgc.h
index 339cc176..ee054179 100644
--- a/lgc.h
+++ b/lgc.h
@@ -224,15 +224,15 @@
224*/ 224*/
225 225
226#if !defined(HARDMEMTESTS) 226#if !defined(HARDMEMTESTS)
227#define condchangemem(L,pre,pos) ((void)0) 227#define condchangemem(L,pre,pos,emg) ((void)0)
228#else 228#else
229#define condchangemem(L,pre,pos) \ 229#define condchangemem(L,pre,pos,emg) \
230 { if (gcrunning(G(L))) { pre; luaC_fullgc(L, 0); pos; } } 230 { if (gcrunning(G(L))) { pre; luaC_fullgc(L, emg); pos; } }
231#endif 231#endif
232 232
233#define luaC_condGC(L,pre,pos) \ 233#define luaC_condGC(L,pre,pos) \
234 { if (G(L)->GCdebt <= 0) { pre; luaC_step(L); pos;}; \ 234 { if (G(L)->GCdebt <= 0) { pre; luaC_step(L); pos;}; \
235 condchangemem(L,pre,pos); } 235 condchangemem(L,pre,pos,0); }
236 236
237/* more often than not, 'pre'/'pos' are empty */ 237/* more often than not, 'pre'/'pos' are empty */
238#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) 238#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0)
diff --git a/ltable.c b/ltable.c
index f6785367..b6b1fa1a 100644
--- a/ltable.c
+++ b/ltable.c
@@ -910,6 +910,8 @@ static void luaH_newkey (lua_State *L, Table *t, const TValue *key,
910 newcheckedkey(t, key, value); /* insert key in grown table */ 910 newcheckedkey(t, key, value); /* insert key in grown table */
911 } 911 }
912 luaC_barrierback(L, obj2gco(t), key); 912 luaC_barrierback(L, obj2gco(t), key);
913 /* for debugging only: any new key may force an emergency collection */
914 condchangemem(L, (void)0, (void)0, 1);
913 } 915 }
914} 916}
915 917