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

Function genstep

extlibs/lua/src/lgc.c:1314–1339  ·  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

1312** in that case, do a minor collection.
1313*/
1314static void genstep (lua_State *L, global_State *g) {
1315 if (g->lastatomic != 0) /* last collection was a bad one? */
1316 stepgenfull(L, g); /* do a full step */
1317 else {
1318 lu_mem majorbase = g->GCestimate; /* memory after last major collection */
1319 lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul);
1320 if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) {
1321 lu_mem numobjs = fullgen(L, g); /* do a major collection */
1322 if (gettotalbytes(g) < majorbase + (majorinc / 2)) {
1323 /* collected at least half of memory growth since last major
1324 collection; keep doing minor collections */
1325 setminordebt(g);
1326 }
1327 else { /* bad collection */
1328 g->lastatomic = numobjs; /* signal that last collection was bad */
1329 setpause(g); /* do a long wait for next (major) collection */
1330 }
1331 }
1332 else { /* regular case; do a minor collection */
1333 youngcollection(L, g);
1334 setminordebt(g);
1335 g->GCestimate = majorbase; /* preserve base value */
1336 }
1337 }
1338 lua_assert(isdecGCmodegen(g));
1339}
1340
1341/* }====================================================== */
1342

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