diff options
author | Mike Pall <mike> | 2024-08-19 20:00:21 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2024-08-19 20:00:21 +0200 |
commit | fb22d0f80f291827a4004e16bc589b54bcc4a3c7 (patch) | |
tree | d56d9e46fe8404e06ef575afff522bf910bb7797 | |
parent | fb5e1c9f0d449a2b987c2c4b29f6cc811242b0a1 (diff) | |
download | luajit-fb22d0f80f291827a4004e16bc589b54bcc4a3c7.tar.gz luajit-fb22d0f80f291827a4004e16bc589b54bcc4a3c7.tar.bz2 luajit-fb22d0f80f291827a4004e16bc589b54bcc4a3c7.zip |
FFI: Drop finalizer table rehash after GC cycle.
Reported by Sergey Kaplun. #1247
-rw-r--r-- | src/lj_gc.c | 7 | ||||
-rw-r--r-- | src/lj_obj.h | 2 |
2 files changed, 1 insertions, 8 deletions
diff --git a/src/lj_gc.c b/src/lj_gc.c index 69e78706..bfa4daa8 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c | |||
@@ -554,7 +554,6 @@ static void gc_finalize(lua_State *L) | |||
554 | setcdataV(L, &tmp, gco2cd(o)); | 554 | setcdataV(L, &tmp, gco2cd(o)); |
555 | tv = lj_tab_set(L, tabref(g->gcroot[GCROOT_FFI_FIN]), &tmp); | 555 | tv = lj_tab_set(L, tabref(g->gcroot[GCROOT_FFI_FIN]), &tmp); |
556 | if (!tvisnil(tv)) { | 556 | if (!tvisnil(tv)) { |
557 | g->gc.nocdatafin = 0; | ||
558 | copyTV(L, &tmp, tv); | 557 | copyTV(L, &tmp, tv); |
559 | setnilV(tv); /* Clear entry in finalizer table. */ | 558 | setnilV(tv); /* Clear entry in finalizer table. */ |
560 | gc_call_finalizer(g, L, &tmp, o); | 559 | gc_call_finalizer(g, L, &tmp, o); |
@@ -689,9 +688,6 @@ static size_t gc_onestep(lua_State *L) | |||
689 | lj_str_resize(L, g->str.mask >> 1); /* Shrink string table. */ | 688 | lj_str_resize(L, g->str.mask >> 1); /* Shrink string table. */ |
690 | if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ | 689 | if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ |
691 | g->gc.state = GCSfinalize; | 690 | g->gc.state = GCSfinalize; |
692 | #if LJ_HASFFI | ||
693 | g->gc.nocdatafin = 1; | ||
694 | #endif | ||
695 | } else { /* Otherwise skip this phase to help the JIT. */ | 691 | } else { /* Otherwise skip this phase to help the JIT. */ |
696 | g->gc.state = GCSpause; /* End of GC cycle. */ | 692 | g->gc.state = GCSpause; /* End of GC cycle. */ |
697 | g->gc.debt = 0; | 693 | g->gc.debt = 0; |
@@ -711,9 +707,6 @@ static size_t gc_onestep(lua_State *L) | |||
711 | g->gc.estimate -= GCFINALIZECOST; | 707 | g->gc.estimate -= GCFINALIZECOST; |
712 | return GCFINALIZECOST; | 708 | return GCFINALIZECOST; |
713 | } | 709 | } |
714 | #if LJ_HASFFI | ||
715 | if (!g->gc.nocdatafin) lj_tab_rehash(L, tabref(g->gcroot[GCROOT_FFI_FIN])); | ||
716 | #endif | ||
717 | g->gc.state = GCSpause; /* End of GC cycle. */ | 710 | g->gc.state = GCSpause; /* End of GC cycle. */ |
718 | g->gc.debt = 0; | 711 | g->gc.debt = 0; |
719 | return 0; | 712 | return 0; |
diff --git a/src/lj_obj.h b/src/lj_obj.h index c0817663..d8b69641 100644 --- a/src/lj_obj.h +++ b/src/lj_obj.h | |||
@@ -595,7 +595,7 @@ typedef struct GCState { | |||
595 | GCSize threshold; /* Memory threshold. */ | 595 | GCSize threshold; /* Memory threshold. */ |
596 | uint8_t currentwhite; /* Current white color. */ | 596 | uint8_t currentwhite; /* Current white color. */ |
597 | uint8_t state; /* GC state. */ | 597 | uint8_t state; /* GC state. */ |
598 | uint8_t nocdatafin; /* No cdata finalizer called. */ | 598 | uint8_t unused0; |
599 | #if LJ_64 | 599 | #if LJ_64 |
600 | uint8_t lightudnum; /* Number of lightuserdata segments - 1. */ | 600 | uint8_t lightudnum; /* Number of lightuserdata segments - 1. */ |
601 | #else | 601 | #else |