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