diff options
| -rw-r--r-- | lgc.c | 19 | ||||
| -rw-r--r-- | lgc.h | 3 |
2 files changed, 10 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.112 2011/09/24 21:12:01 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.113 2011/10/03 16:22:05 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 | */ |
| @@ -789,10 +789,10 @@ static void GCTM (lua_State *L, int propagateerrors) { | |||
| 789 | 789 | ||
| 790 | 790 | ||
| 791 | /* | 791 | /* |
| 792 | ** move all unreachable objects that need finalization from list 'finobj' | 792 | ** move all unreachable objects (or 'all' objects) that need |
| 793 | ** to list 'tobefnz' | 793 | ** finalization from list 'finobj' to list 'tobefnz' (to be finalized) |
| 794 | */ | 794 | */ |
| 795 | void luaC_separateudata (lua_State *L, int all) { | 795 | static void separatetobefnz (lua_State *L, int all) { |
| 796 | global_State *g = G(L); | 796 | global_State *g = G(L); |
| 797 | GCObject **p = &g->finobj; | 797 | GCObject **p = &g->finobj; |
| 798 | GCObject *curr; | 798 | GCObject *curr; |
| @@ -888,14 +888,13 @@ static void callallpendingfinalizers (lua_State *L, int propagateerrors) { | |||
| 888 | void luaC_freeallobjects (lua_State *L) { | 888 | void luaC_freeallobjects (lua_State *L) { |
| 889 | global_State *g = G(L); | 889 | global_State *g = G(L); |
| 890 | int i; | 890 | int i; |
| 891 | separatetobefnz(L, 1); /* separate all objects with finalizers */ | ||
| 892 | lua_assert(g->finobj == NULL); | ||
| 891 | callallpendingfinalizers(L, 0); | 893 | callallpendingfinalizers(L, 0); |
| 892 | /* following "white" makes all objects look dead */ | 894 | g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ |
| 893 | g->currentwhite = WHITEBITS; | ||
| 894 | g->gckind = KGC_NORMAL; | 895 | g->gckind = KGC_NORMAL; |
| 895 | sweepwholelist(L, &g->finobj); | 896 | sweepwholelist(L, &g->finobj); /* finalizers can create objs. in 'finobj' */ |
| 896 | lua_assert(g->finobj == NULL); | ||
| 897 | sweepwholelist(L, &g->allgc); | 897 | sweepwholelist(L, &g->allgc); |
| 898 | lua_assert(g->allgc == NULL); | ||
| 899 | for (i = 0; i < g->strt.size; i++) /* free all string lists */ | 898 | for (i = 0; i < g->strt.size; i++) /* free all string lists */ |
| 900 | sweepwholelist(L, &g->strt.hash[i]); | 899 | sweepwholelist(L, &g->strt.hash[i]); |
| 901 | lua_assert(g->strt.nuse == 0); | 900 | lua_assert(g->strt.nuse == 0); |
| @@ -920,7 +919,7 @@ static void atomic (lua_State *L) { | |||
| 920 | clearvalues(g->weak, NULL); | 919 | clearvalues(g->weak, NULL); |
| 921 | clearvalues(g->allweak, NULL); | 920 | clearvalues(g->allweak, NULL); |
| 922 | origweak = g->weak; origall = g->allweak; | 921 | origweak = g->weak; origall = g->allweak; |
| 923 | luaC_separateudata(L, 0); /* separate objects to be finalized */ | 922 | separatetobefnz(L, 0); /* separate objects to be finalized */ |
| 924 | markbeingfnz(g); /* mark userdata that will be finalized */ | 923 | markbeingfnz(g); /* mark userdata that will be finalized */ |
| 925 | propagateall(g); /* remark, to propagate `preserveness' */ | 924 | propagateall(g); /* remark, to propagate `preserveness' */ |
| 926 | convergeephemerons(g); | 925 | convergeephemerons(g); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.h,v 2.50 2011/01/26 16:30:02 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.51 2011/09/30 12:44:19 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 | */ |
| @@ -122,7 +122,6 @@ | |||
| 122 | #define luaC_barrierproto(L,p,c) \ | 122 | #define luaC_barrierproto(L,p,c) \ |
| 123 | { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } | 123 | { if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); } |
| 124 | 124 | ||
| 125 | LUAI_FUNC void luaC_separateudata (lua_State *L, int all); | ||
| 126 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); | 125 | LUAI_FUNC void luaC_freeallobjects (lua_State *L); |
| 127 | LUAI_FUNC void luaC_step (lua_State *L); | 126 | LUAI_FUNC void luaC_step (lua_State *L); |
| 128 | LUAI_FUNC void luaC_forcestep (lua_State *L); | 127 | LUAI_FUNC void luaC_forcestep (lua_State *L); |
