|
@@ -501,6 +501,7 @@ static void gc_finalize(lua_State *L)
|
|
|
setcdataV(L, &tmp, gco2cd(o));
|
|
|
tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp);
|
|
|
if (!tvisnil(tv)) {
|
|
|
+ g->gc.nocdatafin = 0;
|
|
|
copyTV(L, &tmp, tv);
|
|
|
setnilV(tv); /* Clear entry in finalizer table. */
|
|
|
gc_call_finalizer(g, L, &tmp, o);
|
|
@@ -634,6 +635,9 @@ static size_t gc_onestep(lua_State *L)
|
|
|
gc_shrink(g, L);
|
|
|
if (gcref(g->gc.mmudata)) { /* Need any finalizations? */
|
|
|
g->gc.state = GCSfinalize;
|
|
|
+#if LJ_HASFFI
|
|
|
+ g->gc.nocdatafin = 1;
|
|
|
+#endif
|
|
|
} else { /* Otherwise skip this phase to help the JIT. */
|
|
|
g->gc.state = GCSpause; /* End of GC cycle. */
|
|
|
g->gc.debt = 0;
|
|
@@ -652,6 +656,9 @@ static size_t gc_onestep(lua_State *L)
|
|
|
g->gc.estimate -= GCFINALIZECOST;
|
|
|
return GCFINALIZECOST;
|
|
|
}
|
|
|
+#if LJ_HASFFI
|
|
|
+ if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer);
|
|
|
+#endif
|
|
|
g->gc.state = GCSpause; /* End of GC cycle. */
|
|
|
g->gc.debt = 0;
|
|
|
return 0;
|