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

Function luaC_fullgc

depends/lua/src/lgc.c:1159–1175  ·  view source on GitHub ↗

** Performs a full GC cycle; if 'isemergency', set a flag to avoid ** some operations which could change the interpreter state in some ** unexpected ways (running finalizers and shrinking some structures). ** Before running the collection, check 'keepinvariant'; if it is true, ** there may be some objects marked as black, so the collector has ** to sweep all objects to turn them back to white (as

Source from the content-addressed store, hash-verified

1157** changed, nothing will be collected).
1158*/
1159void luaC_fullgc (lua_State *L, int isemergency) {
1160 global_State *g = G(L);
1161 lua_assert(g->gckind == KGC_NORMAL);
1162 if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */
1163 if (keepinvariant(g)) { /* black objects? */
1164 entersweep(L); /* sweep everything to turn them back to white */
1165 }
1166 /* finish any pending sweep phase to start a new cycle */
1167 luaC_runtilstate(L, bitmask(GCSpause));
1168 luaC_runtilstate(L, ~bitmask(GCSpause)); /* start new collection */
1169 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */
1170 /* estimate must be correct after a full GC cycle */
1171 lua_assert(g->GCestimate == gettotalbytes(g));
1172 luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */
1173 g->gckind = KGC_NORMAL;
1174 setpause(g);
1175}
1176
1177/* }====================================================== */
1178

Callers 2

luaM_realloc_Function · 0.85
lua_gcFunction · 0.85

Calls 3

entersweepFunction · 0.85
luaC_runtilstateFunction · 0.85
setpauseFunction · 0.85

Tested by

no test coverage detected