mirror of
https://github.com/lua/lua
synced 2024-11-22 12:51:30 +03:00
Details
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:
parent
71f70df327
commit
b4c353434f
30
lgc.c
30
lgc.c
@ -932,15 +932,15 @@ static GCObject **findlast (GCObject **p) {
|
||||
/*
|
||||
** Move all unreachable objects (or 'all' objects) that need
|
||||
** finalization from list 'finobj' to list 'tobefnz' (to be finalized).
|
||||
** (Note that objects after 'finobjold' cannot be white, so they
|
||||
** don't need to be traversed. In incremental mode, 'finobjold' is NULL,
|
||||
** (Note that objects after 'finobjold1' cannot be white, so they
|
||||
** don't need to be traversed. In incremental mode, 'finobjold1' is NULL,
|
||||
** so the whole list is traversed.)
|
||||
*/
|
||||
static void separatetobefnz (global_State *g, int all) {
|
||||
GCObject *curr;
|
||||
GCObject **p = &g->finobj;
|
||||
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));
|
||||
if (!(iswhite(curr) || all)) /* not being collected? */
|
||||
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 */
|
||||
if (o == g->survival)
|
||||
g->survival = o->next;
|
||||
if (o == g->old)
|
||||
g->old = o->next;
|
||||
if (o == g->old1)
|
||||
g->old1 = o->next;
|
||||
if (o == g->reallyold)
|
||||
g->reallyold = o->next;
|
||||
}
|
||||
@ -1178,17 +1178,17 @@ static void youngcollection (lua_State *L, global_State *g) {
|
||||
g->gcstate = GCSswpallgc;
|
||||
psurvival = sweepgen(L, g, &g->allgc, g->survival);
|
||||
/* sweep 'survival' */
|
||||
sweepgen(L, g, psurvival, g->old);
|
||||
g->reallyold = g->old;
|
||||
g->old = *psurvival; /* 'survival' survivals are old now */
|
||||
sweepgen(L, g, psurvival, g->old1);
|
||||
g->reallyold = g->old1;
|
||||
g->old1 = *psurvival; /* 'survival' survivals are old now */
|
||||
g->survival = g->allgc; /* all news are survivals */
|
||||
|
||||
/* repeat for 'finobj' lists */
|
||||
psurvival = sweepgen(L, g, &g->finobj, g->finobjsur);
|
||||
/* sweep 'survival' */
|
||||
sweepgen(L, g, psurvival, g->finobjold);
|
||||
g->finobjrold = g->finobjold;
|
||||
g->finobjold = *psurvival; /* 'survival' survivals are old now */
|
||||
sweepgen(L, g, psurvival, g->finobjold1);
|
||||
g->finobjrold = g->finobjold1;
|
||||
g->finobjold1 = *psurvival; /* 'survival' survivals are old now */
|
||||
g->finobjsur = g->finobj; /* all news are survivals */
|
||||
|
||||
sweepgen(L, g, &g->tobefnz, NULL);
|
||||
@ -1202,11 +1202,11 @@ static void atomic2gen (lua_State *L, global_State *g) {
|
||||
g->gcstate = GCSswpallgc;
|
||||
sweep2old(L, &g->allgc);
|
||||
/* 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 */
|
||||
sweep2old(L, &g->finobj);
|
||||
g->finobjrold = g->finobjold = g->finobjsur = g->finobj;
|
||||
g->finobjrold = g->finobjold1 = g->finobjsur = g->finobj;
|
||||
|
||||
sweep2old(L, &g->tobefnz);
|
||||
|
||||
@ -1239,10 +1239,10 @@ static lu_mem entergen (lua_State *L, global_State *g) {
|
||||
*/
|
||||
static void enterinc (global_State *g) {
|
||||
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->tobefnz);
|
||||
g->finobjrold = g->finobjold = g->finobjsur = NULL;
|
||||
g->finobjrold = g->finobjold1 = g->finobjsur = NULL;
|
||||
g->gcstate = GCSpause;
|
||||
g->gckind = KGC_INC;
|
||||
g->lastatomic = 0;
|
||||
|
4
lstate.c
4
lstate.c
@ -413,8 +413,8 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
|
||||
g->gckind = KGC_INC;
|
||||
g->gcemergency = 0;
|
||||
g->finobj = g->tobefnz = g->fixedgc = NULL;
|
||||
g->survival = g->old = g->reallyold = NULL;
|
||||
g->finobjsur = g->finobjold = g->finobjrold = NULL;
|
||||
g->survival = g->old1 = g->reallyold = NULL;
|
||||
g->finobjsur = g->finobjold1 = g->finobjrold = NULL;
|
||||
g->sweepgc = NULL;
|
||||
g->gray = g->grayagain = NULL;
|
||||
g->weak = g->ephemeron = g->allweak = NULL;
|
||||
|
19
lstate.h
19
lstate.h
@ -32,13 +32,20 @@
|
||||
**
|
||||
** 'allgc' -> 'survival': new objects;
|
||||
** '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.
|
||||
**
|
||||
** 'finobj' -> 'finobjsur': new objects marked for finalization;
|
||||
** 'finobjsur' -> 'finobjold': survived """";
|
||||
** 'finobjold' -> 'finobjrold': just old """";
|
||||
** 'finobjsur' -> 'finobjold1': survived """";
|
||||
** 'finobjold1' -> 'finobjrold': just 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 */
|
||||
/* fields for generational collector */
|
||||
GCObject *survival; /* start of objects that survived one GC cycle */
|
||||
GCObject *old; /* start of old objects */
|
||||
GCObject *reallyold; /* old objects with more than one cycle */
|
||||
GCObject *old1; /* start of old1 objects */
|
||||
GCObject *reallyold; /* objects more than one cycle old ("really old") */
|
||||
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 */
|
||||
struct lua_State *twups; /* list of threads with open upvalues */
|
||||
lua_CFunction panic; /* to be called in unprotected errors */
|
||||
|
4
ltests.c
4
ltests.c
@ -586,10 +586,10 @@ int lua_checkmemory (lua_State *L) {
|
||||
|
||||
/* check 'allgc' list */
|
||||
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 */
|
||||
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 */
|
||||
for (o = g->tobefnz; o != NULL; o = o->next) {
|
||||
|
Loading…
Reference in New Issue
Block a user