MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / genstep

Function genstep

xrepo/packages/l/lua/port/lua/src/lgc.c:1415–1440  ·  view source on GitHub ↗

** Does a generational "step". ** Usually, this means doing a minor collection and setting the debt to ** make another collection when memory grows 'genminormul'% larger. ** ** However, there are exceptions. If memory grows 'genmajormul'% ** larger than it was at the end of the last major collection (kept ** in 'g->GCestimate'), the function does a major collection. At the ** end, it checks wheth

Source from the content-addressed store, hash-verified

1413** in that case, do a minor collection.
1414*/
1415static void genstep (lua_State *L, global_State *g) {
1416 if (g->lastatomic != 0) /* last collection was a bad one? */
1417 stepgenfull(L, g); /* do a full step */
1418 else {
1419 lu_mem majorbase = g->GCestimate; /* memory after last major collection */
1420 lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul);
1421 if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) {
1422 lu_mem numobjs = fullgen(L, g); /* do a major collection */
1423 if (gettotalbytes(g) < majorbase + (majorinc / 2)) {
1424 /* collected at least half of memory growth since last major
1425 collection; keep doing minor collections */
1426 setminordebt(g);
1427 }
1428 else { /* bad collection */
1429 g->lastatomic = numobjs; /* signal that last collection was bad */
1430 setpause(g); /* do a long wait for next (major) collection */
1431 }
1432 }
1433 else { /* regular case; do a minor collection */
1434 youngcollection(L, g);
1435 setminordebt(g);
1436 g->GCestimate = majorbase; /* preserve base value */
1437 }
1438 }
1439 lua_assert(isdecGCmodegen(g));
1440}
1441
1442/* }====================================================== */
1443

Callers 1

luaC_stepFunction · 0.85

Calls 5

stepgenfullFunction · 0.85
fullgenFunction · 0.85
setminordebtFunction · 0.85
setpauseFunction · 0.85
youngcollectionFunction · 0.85

Tested by

no test coverage detected