The fields 'old' and 'finobjold' were renamed 'old1' and 'finobjold1',
respectively, to make clearer the main ages of their elements.
This commit is contained in:
Roberto Ierusalimschy 2020-07-29 11:34:08 -03:00
parent 71f70df327
commit b4c353434f
4 changed files with 32 additions and 25 deletions

30
lgc.c
View File

@ -932,15 +932,15 @@ static GCObject **findlast (GCObject **p) {
/* /*
** Move all unreachable objects (or 'all' objects) that need ** Move all unreachable objects (or 'all' objects) that need
** finalization from list 'finobj' to list 'tobefnz' (to be finalized). ** finalization from list 'finobj' to list 'tobefnz' (to be finalized).
** (Note that objects after 'finobjold' cannot be white, so they ** (Note that objects after 'finobjold1' cannot be white, so they
** don't need to be traversed. In incremental mode, 'finobjold' is NULL, ** don't need to be traversed. In incremental mode, 'finobjold1' is NULL,
** so the whole list is traversed.) ** so the whole list is traversed.)
*/ */
static void separatetobefnz (global_State *g, int all) { static void separatetobefnz (global_State *g, int all) {
GCObject *curr; GCObject *curr;
GCObject **p = &g->finobj; GCObject **p = &g->finobj;
GCObject **lastnext = findlast(&g->tobefnz); GCObject **lastnext = findlast(&g->tobefnz);
while ((curr = *p) != g->finobjold) { /* traverse all finalizable objects */ while ((curr = *p) != g->finobjold1) { /* traverse all finalizable objects */
lua_assert(tofinalize(curr)); lua_assert(tofinalize(curr));
if (!(iswhite(curr) || all)) /* not being collected? */ if (!(iswhite(curr) || all)) /* not being collected? */
p = &curr->next; /* don't bother with it */ p = &curr->next; /* don't bother with it */
@ -975,8 +975,8 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
else { /* correct pointers into 'allgc' list, if needed */ else { /* correct pointers into 'allgc' list, if needed */
if (o == g->survival) if (o == g->survival)
g->survival = o->next; g->survival = o->next;
if (o == g->old) if (o == g->old1)
g->old = o->next; g->old1 = o->next;
if (o == g->reallyold) if (o == g->reallyold)
g->reallyold = o->next; g->reallyold = o->next;
} }
@ -1178,17 +1178,17 @@ static void youngcollection (lua_State *L, global_State *g) {
g->gcstate = GCSswpallgc; g->gcstate = GCSswpallgc;
psurvival = sweepgen(L, g, &g->allgc, g->survival); psurvival = sweepgen(L, g, &g->allgc, g->survival);
/* sweep 'survival' */ /* sweep 'survival' */
sweepgen(L, g, psurvival, g->old); sweepgen(L, g, psurvival, g->old1);
g->reallyold = g->old; g->reallyold = g->old1;
g->old = *psurvival; /* 'survival' survivals are old now */ g->old1 = *psurvival; /* 'survival' survivals are old now */
g->survival = g->allgc; /* all news are survivals */ g->survival = g->allgc; /* all news are survivals */
/* repeat for 'finobj' lists */ /* repeat for 'finobj' lists */
psurvival = sweepgen(L, g, &g->finobj, g->finobjsur); psurvival = sweepgen(L, g, &g->finobj, g->finobjsur);
/* sweep 'survival' */ /* sweep 'survival' */
sweepgen(L, g, psurvival, g->finobjold); sweepgen(L, g, psurvival, g->finobjold1);
g->finobjrold = g->finobjold; g->finobjrold = g->finobjold1;
g->finobjold = *psurvival; /* 'survival' survivals are old now */ g->finobjold1 = *psurvival; /* 'survival' survivals are old now */
g->finobjsur = g->finobj; /* all news are survivals */ g->finobjsur = g->finobj; /* all news are survivals */
sweepgen(L, g, &g->tobefnz, NULL); sweepgen(L, g, &g->tobefnz, NULL);
@ -1202,11 +1202,11 @@ static void atomic2gen (lua_State *L, global_State *g) {
g->gcstate = GCSswpallgc; g->gcstate = GCSswpallgc;
sweep2old(L, &g->allgc); sweep2old(L, &g->allgc);
/* everything alive now is old */ /* everything alive now is old */
g->reallyold = g->old = g->survival = g->allgc; g->reallyold = g->old1 = g->survival = g->allgc;
/* repeat for 'finobj' lists */ /* repeat for 'finobj' lists */
sweep2old(L, &g->finobj); sweep2old(L, &g->finobj);
g->finobjrold = g->finobjold = g->finobjsur = g->finobj; g->finobjrold = g->finobjold1 = g->finobjsur = g->finobj;
sweep2old(L, &g->tobefnz); sweep2old(L, &g->tobefnz);
@ -1239,10 +1239,10 @@ static lu_mem entergen (lua_State *L, global_State *g) {
*/ */
static void enterinc (global_State *g) { static void enterinc (global_State *g) {
whitelist(g, g->allgc); whitelist(g, g->allgc);
g->reallyold = g->old = g->survival = NULL; g->reallyold = g->old1 = g->survival = NULL;
whitelist(g, g->finobj); whitelist(g, g->finobj);
whitelist(g, g->tobefnz); whitelist(g, g->tobefnz);
g->finobjrold = g->finobjold = g->finobjsur = NULL; g->finobjrold = g->finobjold1 = g->finobjsur = NULL;
g->gcstate = GCSpause; g->gcstate = GCSpause;
g->gckind = KGC_INC; g->gckind = KGC_INC;
g->lastatomic = 0; g->lastatomic = 0;

View File

@ -413,8 +413,8 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g->gckind = KGC_INC; g->gckind = KGC_INC;
g->gcemergency = 0; g->gcemergency = 0;
g->finobj = g->tobefnz = g->fixedgc = NULL; g->finobj = g->tobefnz = g->fixedgc = NULL;
g->survival = g->old = g->reallyold = NULL; g->survival = g->old1 = g->reallyold = NULL;
g->finobjsur = g->finobjold = g->finobjrold = NULL; g->finobjsur = g->finobjold1 = g->finobjrold = NULL;
g->sweepgc = NULL; g->sweepgc = NULL;
g->gray = g->grayagain = NULL; g->gray = g->grayagain = NULL;
g->weak = g->ephemeron = g->allweak = NULL; g->weak = g->ephemeron = g->allweak = NULL;

View File

@ -32,13 +32,20 @@
** **
** 'allgc' -> 'survival': new objects; ** 'allgc' -> 'survival': new objects;
** 'survival' -> 'old': objects that survived one collection; ** 'survival' -> 'old': objects that survived one collection;
** 'old' -> 'reallyold': objects that became old in last collection; ** 'old1' -> 'reallyold': objects that became old in last collection;
** 'reallyold' -> NULL: objects old for more than one cycle. ** 'reallyold' -> NULL: objects old for more than one cycle.
** **
** 'finobj' -> 'finobjsur': new objects marked for finalization; ** 'finobj' -> 'finobjsur': new objects marked for finalization;
** 'finobjsur' -> 'finobjold': survived """"; ** 'finobjsur' -> 'finobjold1': survived """";
** 'finobjold' -> 'finobjrold': just old """"; ** 'finobjold1' -> 'finobjrold': just old """";
** 'finobjrold' -> NULL: really old """". ** 'finobjrold' -> NULL: really old """".
**
** All lists can contain elements older than their main ages, due
** to 'luaC_checkfinalizer' and 'udata2finalize', which move
** objects between the normal lists and the "marked for finalization"
** lists. Moreover, barriers can age young objects in young lists as
** OLD0, which then become OLD1. However, a list never contains
** elements younger than their main ages.
*/ */
/* /*
@ -257,10 +264,10 @@ typedef struct global_State {
GCObject *fixedgc; /* list of objects not to be collected */ GCObject *fixedgc; /* list of objects not to be collected */
/* fields for generational collector */ /* fields for generational collector */
GCObject *survival; /* start of objects that survived one GC cycle */ GCObject *survival; /* start of objects that survived one GC cycle */
GCObject *old; /* start of old objects */ GCObject *old1; /* start of old1 objects */
GCObject *reallyold; /* old objects with more than one cycle */ GCObject *reallyold; /* objects more than one cycle old ("really old") */
GCObject *finobjsur; /* list of survival objects with finalizers */ GCObject *finobjsur; /* list of survival objects with finalizers */
GCObject *finobjold; /* list of old objects with finalizers */ GCObject *finobjold1; /* list of old1 objects with finalizers */
GCObject *finobjrold; /* list of really old objects with finalizers */ GCObject *finobjrold; /* list of really old objects with finalizers */
struct lua_State *twups; /* list of threads with open upvalues */ struct lua_State *twups; /* list of threads with open upvalues */
lua_CFunction panic; /* to be called in unprotected errors */ lua_CFunction panic; /* to be called in unprotected errors */

View File

@ -586,10 +586,10 @@ int lua_checkmemory (lua_State *L) {
/* check 'allgc' list */ /* check 'allgc' list */
maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc);
checklist(g, maybedead, 0, g->allgc, g->survival, g->old, g->reallyold); checklist(g, maybedead, 0, g->allgc, g->survival, g->old1, g->reallyold);
/* check 'finobj' list */ /* check 'finobj' list */
checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold, g->finobjrold); checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold1, g->finobjrold);
/* check 'tobefnz' list */ /* check 'tobefnz' list */
for (o = g->tobefnz; o != NULL; o = o->next) { for (o = g->tobefnz; o != NULL; o = o->next) {