aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lgc.c b/lgc.c
index d3f5b5b7..42a73d81 100644
--- a/lgc.c
+++ b/lgc.c
@@ -907,7 +907,7 @@ static void GCTM (lua_State *L) {
907 int status; 907 int status;
908 lu_byte oldah = L->allowhook; 908 lu_byte oldah = L->allowhook;
909 int oldgcstp = g->gcstp; 909 int oldgcstp = g->gcstp;
910 g->gcstp = GCSTPGC; /* avoid GC steps */ 910 g->gcstp |= GCSTPGC; /* avoid GC steps */
911 L->allowhook = 0; /* stop debug hooks during GC metamethod */ 911 L->allowhook = 0; /* stop debug hooks during GC metamethod */
912 setobj2s(L, L->top++, tm); /* push finalizer... */ 912 setobj2s(L, L->top++, tm); /* push finalizer... */
913 setobj2s(L, L->top++, &v); /* ... and its argument */ 913 setobj2s(L, L->top++, &v); /* ... and its argument */
@@ -1011,7 +1011,8 @@ static void correctpointers (global_State *g, GCObject *o) {
1011void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { 1011void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
1012 global_State *g = G(L); 1012 global_State *g = G(L);
1013 if (tofinalize(o) || /* obj. is already marked... */ 1013 if (tofinalize(o) || /* obj. is already marked... */
1014 gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ 1014 gfasttm(g, mt, TM_GC) == NULL || /* or has no finalizer... */
1015 (g->gcstp & GCSTPCLS)) /* or closing state? */
1015 return; /* nothing to be done */ 1016 return; /* nothing to be done */
1016 else { /* move 'o' to 'finobj' list */ 1017 else { /* move 'o' to 'finobj' list */
1017 GCObject **p; 1018 GCObject **p;
@@ -1502,14 +1503,13 @@ static void deletelist (lua_State *L, GCObject *p, GCObject *limit) {
1502*/ 1503*/
1503void luaC_freeallobjects (lua_State *L) { 1504void luaC_freeallobjects (lua_State *L) {
1504 global_State *g = G(L); 1505 global_State *g = G(L);
1505 g->gcstp = GCSTPGC; 1506 g->gcstp = GCSTPCLS; /* no extra finalizers after here */
1506 luaC_changemode(L, KGC_INC); 1507 luaC_changemode(L, KGC_INC);
1507 separatetobefnz(g, 1); /* separate all objects with finalizers */ 1508 separatetobefnz(g, 1); /* separate all objects with finalizers */
1508 lua_assert(g->finobj == NULL); 1509 lua_assert(g->finobj == NULL);
1509 g->gcstp = 0;
1510 callallpendingfinalizers(L); 1510 callallpendingfinalizers(L);
1511 deletelist(L, g->allgc, obj2gco(g->mainthread)); 1511 deletelist(L, g->allgc, obj2gco(g->mainthread));
1512 deletelist(L, g->finobj, NULL); 1512 lua_assert(g->finobj == NULL); /* no new finalizers */
1513 deletelist(L, g->fixedgc, NULL); /* collect fixed objects */ 1513 deletelist(L, g->fixedgc, NULL); /* collect fixed objects */
1514 lua_assert(g->strt.nuse == 0); 1514 lua_assert(g->strt.nuse == 0);
1515} 1515}