** Does a young collection. First, mark 'OLD1' objects. Then does the ** atomic step. Then, check whether to continue in minor mode. If so, ** sweep all lists and advance pointers. Finally, finish the collection. */
| 1333 | ** sweep all lists and advance pointers. Finally, finish the collection. |
| 1334 | */ |
| 1335 | static void youngcollection (lua_State *L, global_State *g) { |
| 1336 | l_mem addedold1 = 0; |
| 1337 | l_mem marked = g->GCmarked; /* preserve 'g->GCmarked' */ |
| 1338 | GCObject **psurvival; /* to point to first non-dead survival object */ |
| 1339 | GCObject *dummy; /* dummy out parameter to 'sweepgen' */ |
| 1340 | lua_assert(g->gcstate == GCSpropagate); |
| 1341 | if (g->firstold1) { /* are there regular OLD1 objects? */ |
| 1342 | markold(g, g->firstold1, g->reallyold); /* mark them */ |
| 1343 | g->firstold1 = NULL; /* no more OLD1 objects (for now) */ |
| 1344 | } |
| 1345 | markold(g, g->finobj, g->finobjrold); |
| 1346 | markold(g, g->tobefnz, NULL); |
| 1347 | |
| 1348 | atomic(L); /* will lose 'g->marked' */ |
| 1349 | |
| 1350 | /* sweep nursery and get a pointer to its last live element */ |
| 1351 | g->gcstate = GCSswpallgc; |
| 1352 | psurvival = sweepgen(L, g, &g->allgc, g->survival, &g->firstold1, &addedold1); |
| 1353 | /* sweep 'survival' */ |
| 1354 | sweepgen(L, g, psurvival, g->old1, &g->firstold1, &addedold1); |
| 1355 | g->reallyold = g->old1; |
| 1356 | g->old1 = *psurvival; /* 'survival' survivals are old now */ |
| 1357 | g->survival = g->allgc; /* all news are survivals */ |
| 1358 | |
| 1359 | /* repeat for 'finobj' lists */ |
| 1360 | dummy = NULL; /* no 'firstold1' optimization for 'finobj' lists */ |
| 1361 | psurvival = sweepgen(L, g, &g->finobj, g->finobjsur, &dummy, &addedold1); |
| 1362 | /* sweep 'survival' */ |
| 1363 | sweepgen(L, g, psurvival, g->finobjold1, &dummy, &addedold1); |
| 1364 | g->finobjrold = g->finobjold1; |
| 1365 | g->finobjold1 = *psurvival; /* 'survival' survivals are old now */ |
| 1366 | g->finobjsur = g->finobj; /* all news are survivals */ |
| 1367 | |
| 1368 | sweepgen(L, g, &g->tobefnz, NULL, &dummy, &addedold1); |
| 1369 | |
| 1370 | /* keep total number of added old1 bytes */ |
| 1371 | g->GCmarked = marked + addedold1; |
| 1372 | |
| 1373 | /* decide whether to shift to major mode */ |
| 1374 | if (checkminormajor(g)) { |
| 1375 | minor2inc(L, g, KGC_GENMAJOR); /* go to major mode */ |
| 1376 | g->GCmarked = 0; /* avoid pause in first major cycle (see 'setpause') */ |
| 1377 | } |
| 1378 | else |
| 1379 | finishgencycle(L, g); /* still in minor mode; finish it */ |
| 1380 | } |
| 1381 | |
| 1382 | |
| 1383 | /* |
no test coverage detected