MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / incstep

Function incstep

lib/lua/src/lgc.c:1667–1683  ·  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

1665** controls when next step will be performed.
1666*/
1667static void incstep (lua_State *L, global_State *g) {
1668 int stepmul = (getgcparam(g->gcstepmul) | 1); /* avoid division by 0 */
1669 l_mem debt = (g->GCdebt / WORK2MEM) * stepmul;
1670 l_mem stepsize = (g->gcstepsize <= log2maxs(l_mem))
1671 ? ((cast(l_mem, 1) << g->gcstepsize) / WORK2MEM) * stepmul
1672 : MAX_LMEM; /* overflow; keep maximum value */
1673 do { /* repeat until pause or enough "credit" (negative debt) */
1674 lu_mem work = singlestep(L); /* perform one single step */
1675 debt -= work;
1676 } while (debt > -stepsize && g->gcstate != GCSpause);
1677 if (g->gcstate == GCSpause)
1678 setpause(g); /* pause until next cycle */
1679 else {
1680 debt = (debt / stepmul) * WORK2MEM; /* convert 'work units' to bytes */
1681 luaE_setdebt(g, debt);
1682 }
1683}
1684
1685/*
1686** Performs a basic GC step if collector is running. (If collector is

Callers 1

luaC_stepFunction · 0.85

Calls 3

singlestepFunction · 0.85
setpauseFunction · 0.85
luaE_setdebtFunction · 0.85

Tested by

no test coverage detected