diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-29 11:34:08 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-29 11:34:08 -0300 |
| commit | b4c353434f28f3e9d4c45e61d42b4fd07d76cad2 (patch) | |
| tree | febb2113f925844131481d3b60846b5624f2cbce | |
| parent | 71f70df3271f6e8ae9e8efcaef3be19f8d37c161 (diff) | |
| download | lua-b4c353434f28f3e9d4c45e61d42b4fd07d76cad2.tar.gz lua-b4c353434f28f3e9d4c45e61d42b4fd07d76cad2.tar.bz2 lua-b4c353434f28f3e9d4c45e61d42b4fd07d76cad2.zip | |
Details
The fields 'old' and 'finobjold' were renamed 'old1' and 'finobjold1',
respectively, to make clearer the main ages of their elements.
| -rw-r--r-- | lgc.c | 30 | ||||
| -rw-r--r-- | lstate.c | 4 | ||||
| -rw-r--r-- | lstate.h | 19 | ||||
| -rw-r--r-- | ltests.c | 4 |
4 files changed, 32 insertions, 25 deletions
| @@ -932,15 +932,15 @@ static GCObject **findlast (GCObject **p) { | |||
| 932 | /* | 932 | /* |
| 933 | ** Move all unreachable objects (or 'all' objects) that need | 933 | ** Move all unreachable objects (or 'all' objects) that need |
| 934 | ** finalization from list 'finobj' to list 'tobefnz' (to be finalized). | 934 | ** finalization from list 'finobj' to list 'tobefnz' (to be finalized). |
| 935 | ** (Note that objects after 'finobjold' cannot be white, so they | 935 | ** (Note that objects after 'finobjold1' cannot be white, so they |
| 936 | ** don't need to be traversed. In incremental mode, 'finobjold' is NULL, | 936 | ** don't need to be traversed. In incremental mode, 'finobjold1' is NULL, |
| 937 | ** so the whole list is traversed.) | 937 | ** so the whole list is traversed.) |
| 938 | */ | 938 | */ |
| 939 | static void separatetobefnz (global_State *g, int all) { | 939 | static void separatetobefnz (global_State *g, int all) { |
| 940 | GCObject *curr; | 940 | GCObject *curr; |
| 941 | GCObject **p = &g->finobj; | 941 | GCObject **p = &g->finobj; |
| 942 | GCObject **lastnext = findlast(&g->tobefnz); | 942 | GCObject **lastnext = findlast(&g->tobefnz); |
| 943 | while ((curr = *p) != g->finobjold) { /* traverse all finalizable objects */ | 943 | while ((curr = *p) != g->finobjold1) { /* traverse all finalizable objects */ |
| 944 | lua_assert(tofinalize(curr)); | 944 | lua_assert(tofinalize(curr)); |
| 945 | if (!(iswhite(curr) || all)) /* not being collected? */ | 945 | if (!(iswhite(curr) || all)) /* not being collected? */ |
| 946 | p = &curr->next; /* don't bother with it */ | 946 | p = &curr->next; /* don't bother with it */ |
| @@ -975,8 +975,8 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { | |||
| 975 | else { /* correct pointers into 'allgc' list, if needed */ | 975 | else { /* correct pointers into 'allgc' list, if needed */ |
| 976 | if (o == g->survival) | 976 | if (o == g->survival) |
| 977 | g->survival = o->next; | 977 | g->survival = o->next; |
| 978 | if (o == g->old) | 978 | if (o == g->old1) |
| 979 | g->old = o->next; | 979 | g->old1 = o->next; |
| 980 | if (o == g->reallyold) | 980 | if (o == g->reallyold) |
| 981 | g->reallyold = o->next; | 981 | g->reallyold = o->next; |
| 982 | } | 982 | } |
| @@ -1178,17 +1178,17 @@ static void youngcollection (lua_State *L, global_State *g) { | |||
| 1178 | g->gcstate = GCSswpallgc; | 1178 | g->gcstate = GCSswpallgc; |
| 1179 | psurvival = sweepgen(L, g, &g->allgc, g->survival); | 1179 | psurvival = sweepgen(L, g, &g->allgc, g->survival); |
| 1180 | /* sweep 'survival' */ | 1180 | /* sweep 'survival' */ |
| 1181 | sweepgen(L, g, psurvival, g->old); | 1181 | sweepgen(L, g, psurvival, g->old1); |
| 1182 | g->reallyold = g->old; | 1182 | g->reallyold = g->old1; |
| 1183 | g->old = *psurvival; /* 'survival' survivals are old now */ | 1183 | g->old1 = *psurvival; /* 'survival' survivals are old now */ |
| 1184 | g->survival = g->allgc; /* all news are survivals */ | 1184 | g->survival = g->allgc; /* all news are survivals */ |
| 1185 | 1185 | ||
| 1186 | /* repeat for 'finobj' lists */ | 1186 | /* repeat for 'finobj' lists */ |
| 1187 | psurvival = sweepgen(L, g, &g->finobj, g->finobjsur); | 1187 | psurvival = sweepgen(L, g, &g->finobj, g->finobjsur); |
| 1188 | /* sweep 'survival' */ | 1188 | /* sweep 'survival' */ |
| 1189 | sweepgen(L, g, psurvival, g->finobjold); | 1189 | sweepgen(L, g, psurvival, g->finobjold1); |
| 1190 | g->finobjrold = g->finobjold; | 1190 | g->finobjrold = g->finobjold1; |
| 1191 | g->finobjold = *psurvival; /* 'survival' survivals are old now */ | 1191 | g->finobjold1 = *psurvival; /* 'survival' survivals are old now */ |
| 1192 | g->finobjsur = g->finobj; /* all news are survivals */ | 1192 | g->finobjsur = g->finobj; /* all news are survivals */ |
| 1193 | 1193 | ||
| 1194 | sweepgen(L, g, &g->tobefnz, NULL); | 1194 | sweepgen(L, g, &g->tobefnz, NULL); |
| @@ -1202,11 +1202,11 @@ static void atomic2gen (lua_State *L, global_State *g) { | |||
| 1202 | g->gcstate = GCSswpallgc; | 1202 | g->gcstate = GCSswpallgc; |
| 1203 | sweep2old(L, &g->allgc); | 1203 | sweep2old(L, &g->allgc); |
| 1204 | /* everything alive now is old */ | 1204 | /* everything alive now is old */ |
| 1205 | g->reallyold = g->old = g->survival = g->allgc; | 1205 | g->reallyold = g->old1 = g->survival = g->allgc; |
| 1206 | 1206 | ||
| 1207 | /* repeat for 'finobj' lists */ | 1207 | /* repeat for 'finobj' lists */ |
| 1208 | sweep2old(L, &g->finobj); | 1208 | sweep2old(L, &g->finobj); |
| 1209 | g->finobjrold = g->finobjold = g->finobjsur = g->finobj; | 1209 | g->finobjrold = g->finobjold1 = g->finobjsur = g->finobj; |
| 1210 | 1210 | ||
| 1211 | sweep2old(L, &g->tobefnz); | 1211 | sweep2old(L, &g->tobefnz); |
| 1212 | 1212 | ||
| @@ -1239,10 +1239,10 @@ static lu_mem entergen (lua_State *L, global_State *g) { | |||
| 1239 | */ | 1239 | */ |
| 1240 | static void enterinc (global_State *g) { | 1240 | static void enterinc (global_State *g) { |
| 1241 | whitelist(g, g->allgc); | 1241 | whitelist(g, g->allgc); |
| 1242 | g->reallyold = g->old = g->survival = NULL; | 1242 | g->reallyold = g->old1 = g->survival = NULL; |
| 1243 | whitelist(g, g->finobj); | 1243 | whitelist(g, g->finobj); |
| 1244 | whitelist(g, g->tobefnz); | 1244 | whitelist(g, g->tobefnz); |
| 1245 | g->finobjrold = g->finobjold = g->finobjsur = NULL; | 1245 | g->finobjrold = g->finobjold1 = g->finobjsur = NULL; |
| 1246 | g->gcstate = GCSpause; | 1246 | g->gcstate = GCSpause; |
| 1247 | g->gckind = KGC_INC; | 1247 | g->gckind = KGC_INC; |
| 1248 | g->lastatomic = 0; | 1248 | g->lastatomic = 0; |
| @@ -413,8 +413,8 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
| 413 | g->gckind = KGC_INC; | 413 | g->gckind = KGC_INC; |
| 414 | g->gcemergency = 0; | 414 | g->gcemergency = 0; |
| 415 | g->finobj = g->tobefnz = g->fixedgc = NULL; | 415 | g->finobj = g->tobefnz = g->fixedgc = NULL; |
| 416 | g->survival = g->old = g->reallyold = NULL; | 416 | g->survival = g->old1 = g->reallyold = NULL; |
| 417 | g->finobjsur = g->finobjold = g->finobjrold = NULL; | 417 | g->finobjsur = g->finobjold1 = g->finobjrold = NULL; |
| 418 | g->sweepgc = NULL; | 418 | g->sweepgc = NULL; |
| 419 | g->gray = g->grayagain = NULL; | 419 | g->gray = g->grayagain = NULL; |
| 420 | g->weak = g->ephemeron = g->allweak = NULL; | 420 | g->weak = g->ephemeron = g->allweak = NULL; |
| @@ -32,13 +32,20 @@ | |||
| 32 | ** | 32 | ** |
| 33 | ** 'allgc' -> 'survival': new objects; | 33 | ** 'allgc' -> 'survival': new objects; |
| 34 | ** 'survival' -> 'old': objects that survived one collection; | 34 | ** 'survival' -> 'old': objects that survived one collection; |
| 35 | ** 'old' -> 'reallyold': objects that became old in last collection; | 35 | ** 'old1' -> 'reallyold': objects that became old in last collection; |
| 36 | ** 'reallyold' -> NULL: objects old for more than one cycle. | 36 | ** 'reallyold' -> NULL: objects old for more than one cycle. |
| 37 | ** | 37 | ** |
| 38 | ** 'finobj' -> 'finobjsur': new objects marked for finalization; | 38 | ** 'finobj' -> 'finobjsur': new objects marked for finalization; |
| 39 | ** 'finobjsur' -> 'finobjold': survived """"; | 39 | ** 'finobjsur' -> 'finobjold1': survived """"; |
| 40 | ** 'finobjold' -> 'finobjrold': just old """"; | 40 | ** 'finobjold1' -> 'finobjrold': just old """"; |
| 41 | ** 'finobjrold' -> NULL: really old """". | 41 | ** 'finobjrold' -> NULL: really old """". |
| 42 | ** | ||
| 43 | ** All lists can contain elements older than their main ages, due | ||
| 44 | ** to 'luaC_checkfinalizer' and 'udata2finalize', which move | ||
| 45 | ** objects between the normal lists and the "marked for finalization" | ||
| 46 | ** lists. Moreover, barriers can age young objects in young lists as | ||
| 47 | ** OLD0, which then become OLD1. However, a list never contains | ||
| 48 | ** elements younger than their main ages. | ||
| 42 | */ | 49 | */ |
| 43 | 50 | ||
| 44 | /* | 51 | /* |
| @@ -257,10 +264,10 @@ typedef struct global_State { | |||
| 257 | GCObject *fixedgc; /* list of objects not to be collected */ | 264 | GCObject *fixedgc; /* list of objects not to be collected */ |
| 258 | /* fields for generational collector */ | 265 | /* fields for generational collector */ |
| 259 | GCObject *survival; /* start of objects that survived one GC cycle */ | 266 | GCObject *survival; /* start of objects that survived one GC cycle */ |
| 260 | GCObject *old; /* start of old objects */ | 267 | GCObject *old1; /* start of old1 objects */ |
| 261 | GCObject *reallyold; /* old objects with more than one cycle */ | 268 | GCObject *reallyold; /* objects more than one cycle old ("really old") */ |
| 262 | GCObject *finobjsur; /* list of survival objects with finalizers */ | 269 | GCObject *finobjsur; /* list of survival objects with finalizers */ |
| 263 | GCObject *finobjold; /* list of old objects with finalizers */ | 270 | GCObject *finobjold1; /* list of old1 objects with finalizers */ |
| 264 | GCObject *finobjrold; /* list of really old objects with finalizers */ | 271 | GCObject *finobjrold; /* list of really old objects with finalizers */ |
| 265 | struct lua_State *twups; /* list of threads with open upvalues */ | 272 | struct lua_State *twups; /* list of threads with open upvalues */ |
| 266 | lua_CFunction panic; /* to be called in unprotected errors */ | 273 | lua_CFunction panic; /* to be called in unprotected errors */ |
| @@ -586,10 +586,10 @@ int lua_checkmemory (lua_State *L) { | |||
| 586 | 586 | ||
| 587 | /* check 'allgc' list */ | 587 | /* check 'allgc' list */ |
| 588 | maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); | 588 | maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); |
| 589 | checklist(g, maybedead, 0, g->allgc, g->survival, g->old, g->reallyold); | 589 | checklist(g, maybedead, 0, g->allgc, g->survival, g->old1, g->reallyold); |
| 590 | 590 | ||
| 591 | /* check 'finobj' list */ | 591 | /* check 'finobj' list */ |
| 592 | checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold, g->finobjrold); | 592 | checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold1, g->finobjrold); |
| 593 | 593 | ||
| 594 | /* check 'tobefnz' list */ | 594 | /* check 'tobefnz' list */ |
| 595 | for (o = g->tobefnz; o != NULL; o = o->next) { | 595 | for (o = g->tobefnz; o != NULL; o = o->next) { |
