MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / youngcollection

Function youngcollection

3rd/lua-5.4.3/src/lgc.c:1224–1256  ·  view source on GitHub ↗

** Does a young collection. First, mark 'OLD1' objects. Then does the ** atomic step. Then, sweep all lists and advance pointers. Finally, ** finish the collection. */

Source from the content-addressed store, hash-verified

1222** finish the collection.
1223*/
1224static void youngcollection (lua_State *L, global_State *g) {
1225 GCObject **psurvival; /* to point to first non-dead survival object */
1226 GCObject *dummy; /* dummy out parameter to 'sweepgen' */
1227 lua_assert(g->gcstate == GCSpropagate);
1228 if (g->firstold1) { /* are there regular OLD1 objects? */
1229 markold(g, g->firstold1, g->reallyold); /* mark them */
1230 g->firstold1 = NULL; /* no more OLD1 objects (for now) */
1231 }
1232 markold(g, g->finobj, g->finobjrold);
1233 markold(g, g->tobefnz, NULL);
1234 atomic(L);
1235
1236 /* sweep nursery and get a pointer to its last live element */
1237 g->gcstate = GCSswpallgc;
1238 psurvival = sweepgen(L, g, &g->allgc, g->survival, &g->firstold1);
1239 /* sweep 'survival' */
1240 sweepgen(L, g, psurvival, g->old1, &g->firstold1);
1241 g->reallyold = g->old1;
1242 g->old1 = *psurvival; /* 'survival' survivals are old now */
1243 g->survival = g->allgc; /* all news are survivals */
1244
1245 /* repeat for 'finobj' lists */
1246 dummy = NULL; /* no 'firstold1' optimization for 'finobj' lists */
1247 psurvival = sweepgen(L, g, &g->finobj, g->finobjsur, &dummy);
1248 /* sweep 'survival' */
1249 sweepgen(L, g, psurvival, g->finobjold1, &dummy);
1250 g->finobjrold = g->finobjold1;
1251 g->finobjold1 = *psurvival; /* 'survival' survivals are old now */
1252 g->finobjsur = g->finobj; /* all news are survivals */
1253
1254 sweepgen(L, g, &g->tobefnz, NULL, &dummy);
1255 finishgencycle(L, g);
1256}
1257
1258
1259/*

Callers 1

genstepFunction · 0.85

Calls 4

markoldFunction · 0.85
atomicFunction · 0.85
sweepgenFunction · 0.85
finishgencycleFunction · 0.85

Tested by

no test coverage detected