void luaC_fullgc (lua_State *L) { global_State *g = G(L); if(is_block_gc(L)) return; set_block_gc(L); if (g->gcstate <= GCSpropagate) { /* reset sweep marks to sweep all elements (returning them to white) */ g->sweepstrgc = 0; g->sweepgc = &g->rootgc; /* reset other collector lists */ g->gray = NULL; g->grayagain = NULL; g->weak = NULL; g->gcstate = GCSsweepstring; } lua_assert(g->gcstate != GCSpause && g->gcstate != GCSpropagate); /* finish any pending sweep phase */ while (g->gcstate != GCSfinalize) { lua_assert(g->gcstate == GCSsweepstring || g->gcstate == GCSsweep); singlestep(L); } markroot(L); while (g->gcstate != GCSpause) { singlestep(L); } setthreshold(g); unset_block_gc(L); }
void luaC_step (lua_State *L) { global_State *g = G(L); if(is_block_gc(L)) return; set_block_gc(L); l_mem lim = (GCSTEPSIZE/100) * g->gcstepmul; if (lim == 0) lim = (MAX_LUMEM-1)/2; /* no limit */ g->gcdept += g->totalbytes - g->GCthreshold; if (g->estimate > g->totalbytes) g->estimate = g->totalbytes; do { lim -= singlestep(L); if (g->gcstate == GCSpause) break; } while (lim > 0); if (g->gcstate != GCSpause) { if (g->gcdept < GCSTEPSIZE) g->GCthreshold = g->totalbytes + GCSTEPSIZE; /* - lim/g->gcstepmul;*/ else { g->gcdept -= GCSTEPSIZE; g->GCthreshold = g->totalbytes; } } else { lua_assert(g->totalbytes >= g->estimate); setthreshold(g); } unset_block_gc(L); }
void luaD_throw (lua_State *L, int errcode) { unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */ unset_block_gc(L); if (L->errorJmp) { L->errorJmp->status = errcode; LUAI_THROW(L, L->errorJmp); } else { L->status = cast_byte(errcode); if (G(L)->panic) { resetstack(L, errcode); lua_unlock(L); G(L)->panic(L); } exit(EXIT_FAILURE); } }
LUALIB_API int load_compiled_protos(lua_State *L, jit_proto *p) { Closure *cl; Proto *tf; int i; // load compiled lua code. luaC_checkGC(L); set_block_gc(L); /* stop collector during jit function loading. */ tf = load_jit_proto(L, p); #if DUMP_PROTOS luaU_dump_proto(tf,2); #endif cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); cl->l.p = tf; for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ cl->l.upvals[i] = luaF_newupval(L); setclvalue(L, L->top, cl); incr_top(L); unset_block_gc(L); return 0; }