diff options
-rw-r--r-- | lgc.c | 10 | ||||
-rw-r--r-- | lstate.c | 16 |
2 files changed, 10 insertions, 16 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.46 2008/06/23 22:07:44 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.47 2008/06/26 19:42:45 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -599,6 +599,12 @@ static Udata *udata2finalize (global_State *g) { | |||
599 | } | 599 | } |
600 | 600 | ||
601 | 601 | ||
602 | static void dothecall (lua_State *L, void *ud) { | ||
603 | UNUSED(ud); | ||
604 | luaD_call(L, L->top - 2, 0); | ||
605 | } | ||
606 | |||
607 | |||
602 | static void GCTM (lua_State *L) { | 608 | static void GCTM (lua_State *L) { |
603 | global_State *g = G(L); | 609 | global_State *g = G(L); |
604 | Udata *udata = udata2finalize(g); | 610 | Udata *udata = udata2finalize(g); |
@@ -611,7 +617,7 @@ static void GCTM (lua_State *L) { | |||
611 | setobj2s(L, L->top, tm); | 617 | setobj2s(L, L->top, tm); |
612 | setuvalue(L, L->top+1, udata); | 618 | setuvalue(L, L->top+1, udata); |
613 | L->top += 2; | 619 | L->top += 2; |
614 | luaD_call(L, L->top - 2, 0); | 620 | luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); |
615 | L->allowhook = oldah; /* restore hooks */ | 621 | L->allowhook = oldah; /* restore hooks */ |
616 | g->GCthreshold = oldt; /* restore threshold */ | 622 | g->GCthreshold = oldt; /* restore threshold */ |
617 | } | 623 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.46 2008/08/13 17:01:33 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.47 2008/08/26 13:27:42 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -199,25 +199,13 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | static void callallgcTM (lua_State *L, void *ud) { | ||
203 | UNUSED(ud); | ||
204 | luaC_callAllGCTM(L); /* call GC metamethods for all udata */ | ||
205 | } | ||
206 | |||
207 | |||
208 | LUA_API void lua_close (lua_State *L) { | 202 | LUA_API void lua_close (lua_State *L) { |
209 | L = G(L)->mainthread; /* only the main thread can be closed */ | 203 | L = G(L)->mainthread; /* only the main thread can be closed */ |
210 | lua_lock(L); | 204 | lua_lock(L); |
211 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 205 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
212 | luaC_separateudata(L, 1); /* separate all udata with GC metamethods */ | 206 | luaC_separateudata(L, 1); /* separate all udata with GC metamethods */ |
213 | lua_assert(L->next == NULL); | 207 | lua_assert(L->next == NULL); |
214 | L->errfunc = 0; /* no error function during GC metamethods */ | 208 | luaC_callAllGCTM(L); /* call GC metamethods for all udata */ |
215 | do { /* repeat until no more errors */ | ||
216 | L->ci = L->base_ci; | ||
217 | L->base = L->top = L->ci->base; | ||
218 | G(L)->nCcalls = 0; | ||
219 | } while (luaD_rawrunprotected(L, callallgcTM, NULL) != LUA_OK); | ||
220 | lua_assert(G(L)->tobefnz == NULL); | ||
221 | luai_userstateclose(L); | 209 | luai_userstateclose(L); |
222 | close_state(L); | 210 | close_state(L); |
223 | } | 211 | } |