diff options
Diffstat (limited to 'src/lib_ffi.c')
-rw-r--r-- | src/lib_ffi.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/lib_ffi.c b/src/lib_ffi.c index ba783173..fb7f86f3 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c | |||
@@ -513,7 +513,7 @@ LJLIB_CF(ffi_new) LJLIB_REC(.) | |||
513 | /* Handle ctype __gc metamethod. Use the fast lookup here. */ | 513 | /* Handle ctype __gc metamethod. Use the fast lookup here. */ |
514 | cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); | 514 | cTValue *tv = lj_tab_getinth(cts->miscmap, -(int32_t)id); |
515 | if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { | 515 | if (tv && tvistab(tv) && (tv = lj_meta_fast(L, tabV(tv), MM_gc))) { |
516 | GCtab *t = cts->finalizer; | 516 | GCtab *t = tabref(G(L)->gcroot[GCROOT_FFI_FIN]); |
517 | if (gcref(t->metatable)) { | 517 | if (gcref(t->metatable)) { |
518 | /* Add to finalizer table, if still enabled. */ | 518 | /* Add to finalizer table, if still enabled. */ |
519 | copyTV(L, lj_tab_set(L, t, o-1), tv); | 519 | copyTV(L, lj_tab_set(L, t, o-1), tv); |
@@ -765,7 +765,7 @@ LJLIB_CF(ffi_abi) LJLIB_REC(.) | |||
765 | return 1; | 765 | return 1; |
766 | } | 766 | } |
767 | 767 | ||
768 | LJLIB_PUSH(top-8) LJLIB_SET(!) /* Store reference to miscmap table. */ | 768 | LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to miscmap table. */ |
769 | 769 | ||
770 | LJLIB_CF(ffi_metatype) | 770 | LJLIB_CF(ffi_metatype) |
771 | { | 771 | { |
@@ -791,8 +791,6 @@ LJLIB_CF(ffi_metatype) | |||
791 | return 1; | 791 | return 1; |
792 | } | 792 | } |
793 | 793 | ||
794 | LJLIB_PUSH(top-7) LJLIB_SET(!) /* Store reference to finalizer table. */ | ||
795 | |||
796 | LJLIB_CF(ffi_gc) LJLIB_REC(.) | 794 | LJLIB_CF(ffi_gc) LJLIB_REC(.) |
797 | { | 795 | { |
798 | GCcdata *cd = ffi_checkcdata(L, 1); | 796 | GCcdata *cd = ffi_checkcdata(L, 1); |
@@ -825,19 +823,6 @@ LJLIB_PUSH(top-2) LJLIB_SET(arch) | |||
825 | 823 | ||
826 | /* ------------------------------------------------------------------------ */ | 824 | /* ------------------------------------------------------------------------ */ |
827 | 825 | ||
828 | /* Create special weak-keyed finalizer table. */ | ||
829 | static GCtab *ffi_finalizer(lua_State *L) | ||
830 | { | ||
831 | /* NOBARRIER: The table is new (marked white). */ | ||
832 | GCtab *t = lj_tab_new(L, 0, 1); | ||
833 | settabV(L, L->top++, t); | ||
834 | setgcref(t->metatable, obj2gco(t)); | ||
835 | setstrV(L, lj_tab_setstr(L, t, lj_str_newlit(L, "__mode")), | ||
836 | lj_str_newlit(L, "k")); | ||
837 | t->nomm = (uint8_t)(~(1u<<MM_mode)); | ||
838 | return t; | ||
839 | } | ||
840 | |||
841 | /* Register FFI module as loaded. */ | 826 | /* Register FFI module as loaded. */ |
842 | static void ffi_register_module(lua_State *L) | 827 | static void ffi_register_module(lua_State *L) |
843 | { | 828 | { |
@@ -853,7 +838,6 @@ LUALIB_API int luaopen_ffi(lua_State *L) | |||
853 | { | 838 | { |
854 | CTState *cts = lj_ctype_init(L); | 839 | CTState *cts = lj_ctype_init(L); |
855 | settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); | 840 | settabV(L, L->top++, (cts->miscmap = lj_tab_new(L, 0, 1))); |
856 | cts->finalizer = ffi_finalizer(L); | ||
857 | LJ_LIB_REG(L, NULL, ffi_meta); | 841 | LJ_LIB_REG(L, NULL, ffi_meta); |
858 | /* NOBARRIER: basemt is a GC root. */ | 842 | /* NOBARRIER: basemt is a GC root. */ |
859 | setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); | 843 | setgcref(basemt_it(G(L), LJ_TCDATA), obj2gco(tabV(L->top-1))); |