commit 71f70df3271f6e8ae9e8efcaef3be19f8d37c161
parent 663f83f647f9199541ce1b60a6496b4124b4fdd3
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 29 Jul 2020 09:57:58 -0300
OLD1 ages advanced by 'markold'
Objects aged OLD1 have their ages advanced by 'markold', which has to
visit them anyway. So, the GC doesn't need to "sweep" the old1 list.
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lgc.c b/lgc.c
@@ -1131,7 +1131,7 @@ static void correctgraylists (global_State *g) {
/*
-** Mark 'OLD1' objects when starting a new young collection.
+** Mark black 'OLD1' objects when starting a new young collection.
** Gray objects are already in some gray list, and so will be visited
** in the atomic step.
*/
@@ -1140,6 +1140,7 @@ static void markold (global_State *g, GCObject *from, GCObject *to) {
for (p = from; p != to; p = p->next) {
if (getage(p) == G_OLD1) {
lua_assert(!iswhite(p));
+ changeage(p, G_OLD1, G_OLD); /* now they are old */
if (isblack(p)) {
black2gray(p); /* should be '2white', but gray works too */
reallymarkobject(g, p);
@@ -1176,16 +1177,16 @@ static void youngcollection (lua_State *L, global_State *g) {
/* sweep nursery and get a pointer to its last live element */
g->gcstate = GCSswpallgc;
psurvival = sweepgen(L, g, &g->allgc, g->survival);
- /* sweep 'survival' and 'old' */
- sweepgen(L, g, psurvival, g->reallyold);
+ /* sweep 'survival' */
+ sweepgen(L, g, psurvival, g->old);
g->reallyold = g->old;
g->old = *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' and 'old' */
- sweepgen(L, g, psurvival, g->finobjrold);
+ /* sweep 'survival' */
+ sweepgen(L, g, psurvival, g->finobjold);
g->finobjrold = g->finobjold;
g->finobjold = *psurvival; /* 'survival' survivals are old now */
g->finobjsur = g->finobj; /* all news are survivals */