aboutsummaryrefslogtreecommitdiff
path: root/src/lj_gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_gc.c')
-rw-r--r--src/lj_gc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lj_gc.c b/src/lj_gc.c
index aa243d13..a5d32ea3 100644
--- a/src/lj_gc.c
+++ b/src/lj_gc.c
@@ -168,12 +168,19 @@ static int gc_traverse_tab(global_State *g, GCtab *t)
168 while ((c = *modestr++)) { 168 while ((c = *modestr++)) {
169 if (c == 'k') weak |= LJ_GC_WEAKKEY; 169 if (c == 'k') weak |= LJ_GC_WEAKKEY;
170 else if (c == 'v') weak |= LJ_GC_WEAKVAL; 170 else if (c == 'v') weak |= LJ_GC_WEAKVAL;
171 else if (c == 'K') weak = (int)(~0u & ~LJ_GC_WEAKVAL);
172 } 171 }
173 if (weak > 0) { /* Weak tables are cleared in the atomic phase. */ 172 if (weak) { /* Weak tables are cleared in the atomic phase. */
174 t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak); 173#if LJ_HASFFI
175 setgcrefr(t->gclist, g->gc.weak); 174 CTState *cts = ctype_ctsG(g);
176 setgcref(g->gc.weak, obj2gco(t)); 175 if (cts && cts->finalizer == t) {
176 weak = (int)(~0u & ~LJ_GC_WEAKVAL);
177 } else
178#endif
179 {
180 t->marked = (uint8_t)((t->marked & ~LJ_GC_WEAK) | weak);
181 setgcrefr(t->gclist, g->gc.weak);
182 setgcref(g->gc.weak, obj2gco(t));
183 }
177 } 184 }
178 } 185 }
179 if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */ 186 if (weak == LJ_GC_WEAK) /* Nothing to mark if both keys/values are weak. */