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

Function incstep

extlibs/lua/src/lgc.c:1545–1561  ·  view source on GitHub ↗

** Performs a basic incremental step. The debt and step size are ** converted from bytes to "units of work"; then the function loops ** running single steps until adding that many units of work or ** finishing a cycle (pause state). Finally, it sets the debt that ** controls when next step will be performed. */

Source from the content-addressed store, hash-verified

1543** controls when next step will be performed.
1544*/
1545static void incstep (lua_State *L, global_State *g) {
1546 int stepmul = (getgcparam(g->gcstepmul) | 1); /* avoid division by 0 */
1547 l_mem debt = (g->GCdebt / WORK2MEM) * stepmul;
1548 l_mem stepsize = (g->gcstepsize <= log2maxs(l_mem))
1549 ? ((cast(l_mem, 1) << g->gcstepsize) / WORK2MEM) * stepmul
1550 : MAX_LMEM; /* overflow; keep maximum value */
1551 do { /* repeat until pause or enough "credit" (negative debt) */
1552 lu_mem work = singlestep(L); /* perform one single step */
1553 debt -= work;
1554 } while (debt > -stepsize && g->gcstate != GCSpause);
1555 if (g->gcstate == GCSpause)
1556 setpause(g); /* pause until next cycle */
1557 else {
1558 debt = (debt / stepmul) * WORK2MEM; /* convert 'work units' to bytes */
1559 luaE_setdebt(g, debt);
1560 }
1561}
1562
1563/*
1564** performs a basic GC step if collector is running

Callers 1

luaC_stepFunction · 0.85

Calls 3

singlestepFunction · 0.85
setpauseFunction · 0.85
luaE_setdebtFunction · 0.85

Tested by

no test coverage detected