MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaC_step

Function luaC_step

depends/lua/src/lgc.c:1129–1147  ·  view source on GitHub ↗

** performs a basic GC step when collector is running */

Source from the content-addressed store, hash-verified

1127** performs a basic GC step when collector is running
1128*/
1129void luaC_step (lua_State *L) {
1130 global_State *g = G(L);
1131 l_mem debt = getdebt(g); /* GC deficit (be paid now) */
1132 if (!g->gcrunning) { /* not running? */
1133 luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */
1134 return;
1135 }
1136 do { /* repeat until pause or enough "credit" (negative debt) */
1137 lu_mem work = singlestep(L); /* perform one single step */
1138 debt -= work;
1139 } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause);
1140 if (g->gcstate == GCSpause)
1141 setpause(g); /* pause until next cycle */
1142 else {
1143 debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */
1144 luaE_setdebt(g, debt);
1145 runafewfinalizers(L);
1146 }
1147}
1148
1149
1150/*

Callers 1

lua_gcFunction · 0.85

Calls 5

getdebtFunction · 0.85
luaE_setdebtFunction · 0.85
singlestepFunction · 0.85
setpauseFunction · 0.85
runafewfinalizersFunction · 0.85

Tested by

no test coverage detected