35 #define GCSWEEPMAX 100 46 #define GCFINALIZECOST 50 53 #define WORK2MEM sizeof(TValue) 64 #define maskcolors (bitmask(BLACKBIT) | WHITEBITS) 67 #define maskgcbits (maskcolors | AGEBITS) 71 #define makewhite(g,x) \ 72 (x->marked = cast_byte((x->marked & ~maskcolors) | luaC_white(g))) 75 #define set2gray(x) resetbits(x->marked, maskcolors) 79 #define set2black(x) \ 80 (x->marked = cast_byte((x->marked & ~WHITEBITS) | bitmask(BLACKBIT))) 83 #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) 85 #define keyiswhite(n) (keyiscollectable(n) && iswhite(gckey(n))) 91 #define gcvalueN(o) (iscollectable(o) ? gcvalue(o) : NULL) 94 #define markvalue(g,o) { checkliveness(g->mainthread,o); \ 95 if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } 97 #define markkey(g, n) { if keyiswhite(n) reallymarkobject(g,gckey(n)); } 99 #define markobject(g,t) { if (iswhite(t)) reallymarkobject(g, obj2gco(t)); } 105 #define markobjectN(g,t) { if (t) markobject(g,t); } 122 #define gnodelast(h) gnode(h, cast_sizet(sizenode(h))) 146 #define linkgclist(o,p) linkgclist_(obj2gco(o), &(o)->gclist, &(p)) 159 #define linkobjgclist(o,p) linkgclist_(obj2gco(o), getgclist(o), &(p)) 187 if (o == NULL)
return 0;
343 for (o = g->
tobefnz; o != NULL; o = o->next) {
366 while ((thread = *p) != NULL) {
445 int hasclears = (h->
alimit > 0);
446 for (n =
gnode(h, 0); n < limit; n++) {
483 for (i = 0; i < asize; i++) {
491 for (i = 0; i < nsize; i++) {
522 for (i = 0; i < asize; i++)
524 for (n =
gnode(h, 0); n < limit; n++) {
538 const char *weakkey, *weakvalue;
544 (weakkey || weakvalue))) {
561 for (i = 0; i < u->
nuvalue; i++)
576 for (i = 0; i < f->
sizek; i++)
580 for (i = 0; i < f->
sizep; i++)
590 for (i = 0; i < cl->nupvalues; i++)
592 return 1 + cl->nupvalues;
602 for (i = 0; i < cl->nupvalues; i++) {
606 return 1 + cl->nupvalues;
631 for (; o < th->
top; o++)
693 while ((w = next) != NULL) {
720 for (; l; l =
gco2t(l)->gclist) {
724 for (n =
gnode(h, 0); n < limit; n++) {
739 for (; l != f; l =
gco2t(l)->gclist) {
744 for (i = 0; i < asize; i++) {
749 for (n =
gnode(h, 0); n < limit; n++) {
816 for (i = 0; *p != NULL && i < countin; i++) {
818 int marked = curr->marked;
830 return (*p == NULL) ? NULL : p;
927 for (i = 0; i < n && g->
tobefnz; i++)
972 curr->next = *lastnext;
974 lastnext = &curr->next;
1020 for (p = &g->
allgc; *p != o; p = &(*p)->next) { }
1049 while ((curr = *p) != NULL) {
1084 static const lu_byte nextage[] = {
1095 while ((curr = *p) != limit) {
1125 for (; p != NULL; p = p->next)
1141 while ((curr = *p) != NULL) {
1162 remove: *p = *
next;
continue;
1163 remain: p =
next;
continue;
1190 for (p = from; p != to; p = p->next) {
1236 g->
old1 = *psurvival;
1319 if (newmode != g->
gckind) {
1375 if (newatomic < lastatomic + (lastatomic >> 3)) {
1452 l_mem threshold, debt;
1456 threshold = (pause <
MAX_LMEM / estimate)
1460 if (debt > 0) debt = 0;
1485 while (p != limit) {
1527 g->
gray = grayagain;
1554 int nextstate,
GCObject **nextlist) {
1579 if (g->
gray == NULL) {
1652 debt = (debt / stepmul) *
WORK2MEM;
#define isdecGCmodegen(g)
static void genstep(lua_State *L, global_State *g)
unsigned short callstatus
static void traverseweakvalue(global_State *g, Table *h)
void luaE_warnerror(lua_State *L, const char *where)
static int traverseudata(global_State *g, Udata *u)
void luaS_remove(lua_State *L, TString *ts)
static void clearbykeys(global_State *g, GCObject *l)
static void youngcollection(lua_State *L, global_State *g)
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
void luaD_callnoyield(lua_State *L, StkId func, int nResults)
#define gfasttm(g, et, e)
void luaC_step(lua_State *L)
static int remarkupvals(global_State *g)
static void separatetobefnz(global_State *g, int all)
#define changeage(o, f, t)
static void traversestrongtable(global_State *g, Table *h)
static void restartcollection(global_State *g)
static int runafewfinalizers(lua_State *L, int n)
#define setgcovalue(L, obj, x)
static void correctgraylists(global_State *g)
static void convergeephemerons(global_State *g)
static void entersweep(lua_State *L)
static void incstep(lua_State *L, global_State *g)
static int traverseLclosure(global_State *g, LClosure *cl)
static void whitelist(global_State *g, GCObject *p)
void luaC_changemode(lua_State *L, int newmode)
static void enterinc(global_State *g)
void luaF_unlinkupval(UpVal *uv)
static lu_mem propagatemark(global_State *g)
static void sweep2old(lua_State *L, GCObject **p)
static void stepgenfull(lua_State *L, global_State *g)
static void checkpointer(GCObject **p, GCObject *o)
void luaC_runtilstate(lua_State *L, int statesmask)
void luaH_free(lua_State *L, Table *t)
void luaS_clearcache(global_State *g)
#define markobjectN(g, t)
static void fullinc(lua_State *L, global_State *g)
static void freeupval(lua_State *L, UpVal *uv)
static void reallymarkobject(global_State *g, GCObject *o)
void luaC_fix(lua_State *L, GCObject *o)
void luaD_shrinkstack(lua_State *L)
basic_thread< reference > thread
static int iscleared(global_State *g, const GCObject *o)
static int traversethread(global_State *g, lua_State *th)
static lu_mem propagateall(global_State *g)
#define linkobjgclist(o, p)
void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
static GCObject ** sweeptolive(lua_State *L, GCObject **p)
static void finishgencycle(lua_State *L, global_State *g)
#define luaM_freemem(L, b, s)
static lu_mem singlestep(lua_State *L)
static GCObject ** correctgraylist(GCObject **p)
static void GCTM(lua_State *L)
static int traverseephemeron(global_State *g, Table *h, int inv)
struct lua_State * mainthread
static void clearbyvalues(global_State *g, GCObject *l, GCObject *f)
static void atomic2gen(lua_State *L, global_State *g)
static void callallpendingfinalizers(lua_State *L)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
static GCObject ** sweeplist(lua_State *L, GCObject **p, int countin, int *countout)
#define luaM_newobject(L, tag, s)
static void setminordebt(global_State *g)
static int traverseproto(global_State *g, Proto *f)
static void clearkey(Node *n)
int luaD_pcall(lua_State *L, Pfunc func, void *u, ptrdiff_t old_top, ptrdiff_t ef)
static GCObject ** findlast(GCObject **p)
static lu_mem fullgen(lua_State *L, global_State *g)
struct Table * mt[LUA_NUMTAGS]
void luaS_resize(lua_State *L, int nsize)
static void freeobj(lua_State *L, GCObject *o)
static lu_mem markbeingfnz(global_State *g)
static void setpause(global_State *g)
void luaE_setdebt(global_State *g, l_mem debt)
static void linkgclist_(GCObject *o, GCObject **pnext, GCObject **list)
#define sizeudata(nuv, nb)
void luaF_freeproto(lua_State *L, Proto *f)
static void checkSizes(lua_State *L, global_State *g)
void luaC_freeallobjects(lua_State *L)
void luaE_freethread(lua_State *L, lua_State *L1)
GCObject * luaC_newobj(lua_State *L, int tt, size_t sz)
static void dothecall(lua_State *L, void *ud)
static void cleargraylists(global_State *g)
static GCObject * udata2finalize(global_State *g)
static GCObject ** getgclist(GCObject *o)
static lu_mem traversetable(global_State *g, Table *h)
LUAI_FUNC unsigned int luaH_realasize(const Table *t)
void luaC_barrierback_(lua_State *L, GCObject *o)
static lu_mem entergen(lua_State *L, global_State *g)
static void correctpointers(global_State *g, GCObject *o)
struct UpVal::@22::@23 open
static lu_mem atomic(lua_State *L)
void luaC_fullgc(lua_State *L, int isemergency)
static void genlink(global_State *g, GCObject *o)
static void markmt(global_State *g)
#define setobj2s(L, o1, o2)
static void deletelist(lua_State *L, GCObject *p, GCObject *limit)
static int traverseCclosure(global_State *g, CClosure *cl)
static GCObject ** sweepgen(lua_State *L, global_State *g, GCObject **p, GCObject *limit, GCObject **pfirstold1)
static void markold(global_State *g, GCObject *from, GCObject *to)
static int sweepstep(lua_State *L, global_State *g, int nextstate, GCObject **nextlist)