• Home
  • Raw
  • Download

Lines Matching +full:- +full:g

67 #define makewhite(g,x)	\  argument
68 (x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g)))
70 #define white2gray(x) resetbits(x->marked, WHITEBITS)
71 #define black2gray(x) resetbit(x->marked, BLACKBIT)
83 #define markvalue(g,o) { checkconsistency(o); \ argument
84 if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
86 #define markobject(g,t) { if (iswhite(t)) reallymarkobject(g, obj2gco(t)); } argument
92 #define markobjectN(g,t) { if (t) markobject(g,t); } argument
94 static void reallymarkobject (global_State *g, GCObject *o);
113 #define linkgclist(o,p) ((o)->gclist = (p), (p) = obj2gco(o))
134 ** table. Non-collectable objects are never removed from weak
139 static int iscleared (global_State *g, const TValue *o) { in iscleared() argument
142 markobject(g, tsvalue(o)); /* strings are 'values', so are never weak */ in iscleared()
156 global_State *g = G(L); in luaC_barrier_() local
157 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); in luaC_barrier_()
158 if (keepinvariant(g)) /* must keep invariant? */ in luaC_barrier_()
159 reallymarkobject(g, v); /* restore invariant */ in luaC_barrier_()
161 lua_assert(issweepphase(g)); in luaC_barrier_()
162 makewhite(g, o); /* mark main obj. as white to avoid other barriers */ in luaC_barrier_()
172 global_State *g = G(L); in luaC_barrierback_() local
173 lua_assert(isblack(t) && !isdead(g, t)); in luaC_barrierback_()
175 linkgclist(t, g->grayagain); in luaC_barrierback_()
186 global_State *g = G(L); in luaC_upvalbarrier_() local
187 GCObject *o = gcvalue(uv->v); in luaC_upvalbarrier_()
189 if (keepinvariant(g)) in luaC_upvalbarrier_()
190 markobject(g, o); in luaC_upvalbarrier_()
195 global_State *g = G(L); in luaC_fix() local
196 lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */ in luaC_fix()
198 g->allgc = o->next; /* remove object from 'allgc' list */ in luaC_fix()
199 o->next = g->fixedgc; /* link it to 'fixedgc' list */ in luaC_fix()
200 g->fixedgc = o; in luaC_fix()
209 global_State *g = G(L); in luaC_newobj() local
211 o->marked = luaC_white(g); in luaC_newobj()
212 o->tt = tt; in luaC_newobj()
213 o->next = g->allgc; in luaC_newobj()
214 g->allgc = o; in luaC_newobj()
235 static void reallymarkobject (global_State *g, GCObject *o) { in reallymarkobject() argument
238 switch (o->tt) { in reallymarkobject()
241 g->GCmemtrav += sizelstring(gco2ts(o)->shrlen); in reallymarkobject()
246 g->GCmemtrav += sizelstring(gco2ts(o)->u.lnglen); in reallymarkobject()
251 markobjectN(g, gco2u(o)->metatable); /* mark its metatable */ in reallymarkobject()
253 g->GCmemtrav += sizeudata(gco2u(o)); in reallymarkobject()
254 getuservalue(g->mainthread, gco2u(o), &uvalue); in reallymarkobject()
255 if (valiswhite(&uvalue)) { /* markvalue(g, &uvalue); */ in reallymarkobject()
262 linkgclist(gco2lcl(o), g->gray); in reallymarkobject()
266 linkgclist(gco2ccl(o), g->gray); in reallymarkobject()
270 linkgclist(gco2t(o), g->gray); in reallymarkobject()
274 linkgclist(gco2th(o), g->gray); in reallymarkobject()
278 linkgclist(gco2p(o), g->gray); in reallymarkobject()
289 static void markmt (global_State *g) { in markmt() argument
292 markobjectN(g, g->mt[i]); in markmt()
297 ** mark all objects in list of being-finalized
299 static void markbeingfnz (global_State *g) { in markbeingfnz() argument
301 for (o = g->tobefnz; o != NULL; o = o->next) in markbeingfnz()
302 markobject(g, o); in markbeingfnz()
307 ** Mark all values stored in marked open upvalues from non-marked threads.
310 ** not-marked threads.
312 static void remarkupvals (global_State *g) { in remarkupvals() argument
314 lua_State **p = &g->twups; in remarkupvals()
317 if (isgray(thread) && thread->openupval != NULL) in remarkupvals()
318 p = &thread->twups; /* keep marked thread with upvalues in the list */ in remarkupvals()
321 *p = thread->twups; /* remove thread from the list */ in remarkupvals()
322 thread->twups = thread; /* mark that it is out of list */ in remarkupvals()
323 for (uv = thread->openupval; uv != NULL; uv = uv->u.open.next) { in remarkupvals()
324 if (uv->u.open.touched) { in remarkupvals()
325 markvalue(g, uv->v); /* remark upvalue's value */ in remarkupvals()
326 uv->u.open.touched = 0; in remarkupvals()
337 static void restartcollection (global_State *g) { in restartcollection() argument
338 g->gray = g->grayagain = NULL; in restartcollection()
339 g->weak = g->allweak = g->ephemeron = NULL; in restartcollection()
340 markobject(g, g->mainthread); in restartcollection()
341 markvalue(g, &g->l_registry); in restartcollection()
342 markmt(g); in restartcollection()
343 markbeingfnz(g); /* mark any finalizing object left from previous cycle */ in restartcollection()
361 static void traverseweakvalue (global_State *g, Table *h) { in traverseweakvalue() argument
365 int hasclears = (h->sizearray > 0); in traverseweakvalue()
372 markvalue(g, gkey(n)); /* mark key */ in traverseweakvalue()
373 if (!hasclears && iscleared(g, gval(n))) /* is there a white value? */ in traverseweakvalue()
377 if (g->gcstate == GCSpropagate) in traverseweakvalue()
378 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ in traverseweakvalue()
380 linkgclist(h, g->weak); /* has to be cleared later */ in traverseweakvalue()
389 ** the atomic phase, if table has any white->white entry, it has to
394 static int traverseephemeron (global_State *g, Table *h) { in traverseephemeron() argument
397 int hasww = 0; /* true if table has entry "white-key -> white-value" */ in traverseephemeron()
401 for (i = 0; i < h->sizearray; i++) { in traverseephemeron()
402 if (valiswhite(&h->array[i])) { in traverseephemeron()
404 reallymarkobject(g, gcvalue(&h->array[i])); in traverseephemeron()
412 else if (iscleared(g, gkey(n))) { /* key is not marked (yet)? */ in traverseephemeron()
415 hasww = 1; /* white-white entry */ in traverseephemeron()
419 reallymarkobject(g, gcvalue(gval(n))); /* mark it now */ in traverseephemeron()
423 if (g->gcstate == GCSpropagate) in traverseephemeron()
424 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ in traverseephemeron()
425 else if (hasww) /* table has white->white entries? */ in traverseephemeron()
426 linkgclist(h, g->ephemeron); /* have to propagate again */ in traverseephemeron()
428 linkgclist(h, g->allweak); /* may have to clean white keys */ in traverseephemeron()
433 static void traversestrongtable (global_State *g, Table *h) { in traversestrongtable() argument
436 for (i = 0; i < h->sizearray; i++) /* traverse array part */ in traversestrongtable()
437 markvalue(g, &h->array[i]); in traversestrongtable()
444 markvalue(g, gkey(n)); /* mark key */ in traversestrongtable()
445 markvalue(g, gval(n)); /* mark value */ in traversestrongtable()
451 static lu_mem traversetable (global_State *g, Table *h) { in traversetable() argument
453 const TValue *mode = gfasttm(g, h->metatable, TM_MODE); in traversetable()
454 markobjectN(g, h->metatable); in traversetable()
461 traverseweakvalue(g, h); in traversetable()
463 traverseephemeron(g, h); in traversetable()
465 linkgclist(h, g->allweak); /* nothing to traverse now */ in traversetable()
468 traversestrongtable(g, h); in traversetable()
469 return sizeof(Table) + sizeof(TValue) * h->sizearray + in traversetable()
479 static int traverseproto (global_State *g, Proto *f) { in traverseproto() argument
481 if (f->cache && iswhite(f->cache)) in traverseproto()
482 f->cache = NULL; /* allow cache to be collected */ in traverseproto()
483 markobjectN(g, f->source); in traverseproto()
484 for (i = 0; i < f->sizek; i++) /* mark literals */ in traverseproto()
485 markvalue(g, &f->k[i]); in traverseproto()
486 for (i = 0; i < f->sizeupvalues; i++) /* mark upvalue names */ in traverseproto()
487 markobjectN(g, f->upvalues[i].name); in traverseproto()
488 for (i = 0; i < f->sizep; i++) /* mark nested protos */ in traverseproto()
489 markobjectN(g, f->p[i]); in traverseproto()
490 for (i = 0; i < f->sizelocvars; i++) /* mark local-variable names */ in traverseproto()
491 markobjectN(g, f->locvars[i].varname); in traverseproto()
492 return sizeof(Proto) + sizeof(Instruction) * f->sizecode + in traverseproto()
493 sizeof(Proto *) * f->sizep + in traverseproto()
494 sizeof(TValue) * f->sizek + in traverseproto()
495 sizeof(int) * f->sizelineinfo + in traverseproto()
496 sizeof(LocVar) * f->sizelocvars + in traverseproto()
497 sizeof(Upvaldesc) * f->sizeupvalues; in traverseproto()
501 static lu_mem traverseCclosure (global_State *g, CClosure *cl) { in traverseCclosure() argument
503 for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */ in traverseCclosure()
504 markvalue(g, &cl->upvalue[i]); in traverseCclosure()
505 return sizeCclosure(cl->nupvalues); in traverseCclosure()
514 static lu_mem traverseLclosure (global_State *g, LClosure *cl) { in traverseLclosure() argument
516 markobjectN(g, cl->p); /* mark its prototype */ in traverseLclosure()
517 for (i = 0; i < cl->nupvalues; i++) { /* mark its upvalues */ in traverseLclosure()
518 UpVal *uv = cl->upvals[i]; in traverseLclosure()
520 if (upisopen(uv) && g->gcstate != GCSinsideatomic) in traverseLclosure()
521 uv->u.open.touched = 1; /* can be marked in 'remarkupvals' */ in traverseLclosure()
523 markvalue(g, uv->v); in traverseLclosure()
526 return sizeLclosure(cl->nupvalues); in traverseLclosure()
530 static lu_mem traversethread (global_State *g, lua_State *th) { in traversethread() argument
531 StkId o = th->stack; in traversethread()
534 lua_assert(g->gcstate == GCSinsideatomic || in traversethread()
535 th->openupval == NULL || isintwups(th)); in traversethread()
536 for (; o < th->top; o++) /* mark live elements in the stack */ in traversethread()
537 markvalue(g, o); in traversethread()
538 if (g->gcstate == GCSinsideatomic) { /* final traversal? */ in traversethread()
539 StkId lim = th->stack + th->stacksize; /* real end of stack */ in traversethread()
540 for (; o < lim; o++) /* clear not-marked stack slice */ in traversethread()
543 if (!isintwups(th) && th->openupval != NULL) { in traversethread()
544 th->twups = g->twups; /* link it back to the list */ in traversethread()
545 g->twups = th; in traversethread()
548 else if (g->gckind != KGC_EMERGENCY) in traversethread()
550 return (sizeof(lua_State) + sizeof(TValue) * th->stacksize + in traversethread()
551 sizeof(CallInfo) * th->nci); in traversethread()
559 static void propagatemark (global_State *g) { in propagatemark() argument
561 GCObject *o = g->gray; in propagatemark()
564 switch (o->tt) { in propagatemark()
567 g->gray = h->gclist; /* remove from 'gray' list */ in propagatemark()
568 size = traversetable(g, h); in propagatemark()
573 g->gray = cl->gclist; /* remove from 'gray' list */ in propagatemark()
574 size = traverseLclosure(g, cl); in propagatemark()
579 g->gray = cl->gclist; /* remove from 'gray' list */ in propagatemark()
580 size = traverseCclosure(g, cl); in propagatemark()
585 g->gray = th->gclist; /* remove from 'gray' list */ in propagatemark()
586 linkgclist(th, g->grayagain); /* insert into 'grayagain' list */ in propagatemark()
588 size = traversethread(g, th); in propagatemark()
593 g->gray = p->gclist; /* remove from 'gray' list */ in propagatemark()
594 size = traverseproto(g, p); in propagatemark()
599 g->GCmemtrav += size; in propagatemark()
603 static void propagateall (global_State *g) { in propagateall() argument
604 while (g->gray) propagatemark(g); in propagateall()
608 static void convergeephemerons (global_State *g) { in convergeephemerons() argument
612 GCObject *next = g->ephemeron; /* get ephemeron list */ in convergeephemerons()
613 g->ephemeron = NULL; /* tables may return to this list when traversed */ in convergeephemerons()
616 next = gco2t(w)->gclist; in convergeephemerons()
617 if (traverseephemeron(g, gco2t(w))) { /* traverse marked some value? */ in convergeephemerons()
618 propagateall(g); /* propagate changes */ in convergeephemerons()
639 static void clearkeys (global_State *g, GCObject *l, GCObject *f) { in clearkeys() argument
640 for (; l != f; l = gco2t(l)->gclist) { in clearkeys()
644 if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { in clearkeys()
658 static void clearvalues (global_State *g, GCObject *l, GCObject *f) { in clearvalues() argument
659 for (; l != f; l = gco2t(l)->gclist) { in clearvalues()
663 for (i = 0; i < h->sizearray; i++) { in clearvalues()
664 TValue *o = &h->array[i]; in clearvalues()
665 if (iscleared(g, o)) /* value was collected? */ in clearvalues()
669 if (!ttisnil(gval(n)) && iscleared(g, gval(n))) { in clearvalues()
679 lua_assert(uv->refcount > 0); in luaC_upvdeccount()
680 uv->refcount--; in luaC_upvdeccount()
681 if (uv->refcount == 0 && !upisopen(uv)) in luaC_upvdeccount()
688 for (i = 0; i < cl->nupvalues; i++) { in freeLclosure()
689 UpVal *uv = cl->upvals[i]; in freeLclosure()
693 luaM_freemem(L, cl, sizeLclosure(cl->nupvalues)); in freeLclosure()
698 switch (o->tt) { in freeobj()
705 luaM_freemem(L, o, sizeCclosure(gco2ccl(o)->nupvalues)); in freeobj()
713 luaM_freemem(L, o, sizelstring(gco2ts(o)->shrlen)); in freeobj()
716 luaM_freemem(L, o, sizelstring(gco2ts(o)->u.lnglen)); in freeobj()
731 ** white; change all non-dead objects back to white, preparing for next
736 global_State *g = G(L); in sweeplist() local
737 int ow = otherwhite(g); in sweeplist()
738 int white = luaC_white(g); /* current white */ in sweeplist()
739 while (*p != NULL && count-- > 0) { in sweeplist()
741 int marked = curr->marked; in sweeplist()
743 *p = curr->next; /* remove 'curr' from list */ in sweeplist()
747 curr->marked = cast_byte((marked & maskcolors) | white); in sweeplist()
748 p = &curr->next; /* go to next element */ in sweeplist()
778 static void checkSizes (lua_State *L, global_State *g) { in checkSizes() argument
779 if (g->gckind != KGC_EMERGENCY) { in checkSizes()
780 l_mem olddebt = g->GCdebt; in checkSizes()
781 if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ in checkSizes()
782 luaS_resize(L, g->strt.size / 2); /* shrink it a little */ in checkSizes()
783 g->GCestimate += g->GCdebt - olddebt; /* update estimate */ in checkSizes()
788 static GCObject *udata2finalize (global_State *g) { in udata2finalize() argument
789 GCObject *o = g->tobefnz; /* get first element */ in udata2finalize()
791 g->tobefnz = o->next; /* remove it from 'tobefnz' list */ in udata2finalize()
792 o->next = g->allgc; /* return it to 'allgc' list */ in udata2finalize()
793 g->allgc = o; in udata2finalize()
794 resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */ in udata2finalize()
795 if (issweepphase(g)) in udata2finalize()
796 makewhite(g, o); /* "sweep" object */ in udata2finalize()
803 luaD_callnoyield(L, L->top - 2, 0); in dothecall()
808 global_State *g = G(L); in GCTM() local
811 setgcovalue(L, &v, udata2finalize(g)); in GCTM()
815 lu_byte oldah = L->allowhook; in GCTM()
816 int running = g->gcrunning; in GCTM()
817 L->allowhook = 0; /* stop debug hooks during GC metamethod */ in GCTM()
818 g->gcrunning = 0; /* avoid GC steps */ in GCTM()
819 setobj2s(L, L->top, tm); /* push finalizer... */ in GCTM()
820 setobj2s(L, L->top + 1, &v); /* ... and its argument */ in GCTM()
821 L->top += 2; /* and (next line) call the finalizer */ in GCTM()
822 L->ci->callstatus |= CIST_FIN; /* will run a finalizer */ in GCTM()
823 status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0); in GCTM()
824 L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */ in GCTM()
825 L->allowhook = oldah; /* restore hooks */ in GCTM()
826 g->gcrunning = running; /* restore state */ in GCTM()
829 const char *msg = (ttisstring(L->top - 1)) in GCTM()
830 ? svalue(L->top - 1) in GCTM()
835 luaD_throw(L, status); /* re-throw error */ in GCTM()
842 ** call a few (up to 'g->gcfinnum') finalizers
845 global_State *g = G(L); in runafewfinalizers() local
847 lua_assert(!g->tobefnz || g->gcfinnum > 0); in runafewfinalizers()
848 for (i = 0; g->tobefnz && i < g->gcfinnum; i++) in runafewfinalizers()
850 g->gcfinnum = (!g->tobefnz) ? 0 /* nothing more to finalize? */ in runafewfinalizers()
851 : g->gcfinnum * 2; /* else call a few more next time */ in runafewfinalizers()
860 global_State *g = G(L); in callallpendingfinalizers() local
861 while (g->tobefnz) in callallpendingfinalizers()
871 p = &(*p)->next; in findlast()
880 static void separatetobefnz (global_State *g, int all) { in separatetobefnz() argument
882 GCObject **p = &g->finobj; in separatetobefnz()
883 GCObject **lastnext = findlast(&g->tobefnz); in separatetobefnz()
887 p = &curr->next; /* don't bother with it */ in separatetobefnz()
889 *p = curr->next; /* remove 'curr' from 'finobj' list */ in separatetobefnz()
890 curr->next = *lastnext; /* link at the end of 'tobefnz' list */ in separatetobefnz()
892 lastnext = &curr->next; in separatetobefnz()
903 global_State *g = G(L); in luaC_checkfinalizer() local
905 gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */ in luaC_checkfinalizer()
909 if (issweepphase(g)) { in luaC_checkfinalizer()
910 makewhite(g, o); /* "sweep" object 'o' */ in luaC_checkfinalizer()
911 if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */ in luaC_checkfinalizer()
912 g->sweepgc = sweeptolive(L, g->sweepgc); /* change 'sweepgc' */ in luaC_checkfinalizer()
915 for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ } in luaC_checkfinalizer()
916 *p = o->next; /* remove 'o' from 'allgc' list */ in luaC_checkfinalizer()
917 o->next = g->finobj; /* link it in 'finobj' list */ in luaC_checkfinalizer()
918 g->finobj = o; in luaC_checkfinalizer()
919 l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */ in luaC_checkfinalizer()
940 static void setpause (global_State *g) { in setpause() argument
942 l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ in setpause()
944 threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ in setpause()
945 ? estimate * g->gcpause /* no overflow */ in setpause()
947 debt = gettotalbytes(g) - threshold; in setpause()
948 luaE_setdebt(g, debt); in setpause()
960 global_State *g = G(L); in entersweep() local
961 g->gcstate = GCSswpallgc; in entersweep()
962 lua_assert(g->sweepgc == NULL); in entersweep()
963 g->sweepgc = sweeplist(L, &g->allgc, 1); in entersweep()
968 global_State *g = G(L); in luaC_freeallobjects() local
969 separatetobefnz(g, 1); /* separate all objects with finalizers */ in luaC_freeallobjects()
970 lua_assert(g->finobj == NULL); in luaC_freeallobjects()
972 lua_assert(g->tobefnz == NULL); in luaC_freeallobjects()
973 g->currentwhite = WHITEBITS; /* this "white" makes all objects look dead */ in luaC_freeallobjects()
974 g->gckind = KGC_NORMAL; in luaC_freeallobjects()
975 sweepwholelist(L, &g->finobj); in luaC_freeallobjects()
976 sweepwholelist(L, &g->allgc); in luaC_freeallobjects()
977 sweepwholelist(L, &g->fixedgc); /* collect fixed objects */ in luaC_freeallobjects()
978 lua_assert(g->strt.nuse == 0); in luaC_freeallobjects()
983 global_State *g = G(L); in atomic() local
986 GCObject *grayagain = g->grayagain; /* save original list */ in atomic()
987 lua_assert(g->ephemeron == NULL && g->weak == NULL); in atomic()
988 lua_assert(!iswhite(g->mainthread)); in atomic()
989 g->gcstate = GCSinsideatomic; in atomic()
990 g->GCmemtrav = 0; /* start counting work */ in atomic()
991 markobject(g, L); /* mark running thread */ in atomic()
993 markvalue(g, &g->l_registry); in atomic()
994 markmt(g); /* mark global metatables */ in atomic()
996 remarkupvals(g); in atomic()
997 propagateall(g); /* propagate changes */ in atomic()
998 work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */ in atomic()
999 g->gray = grayagain; in atomic()
1000 propagateall(g); /* traverse 'grayagain' list */ in atomic()
1001 g->GCmemtrav = 0; /* restart counting */ in atomic()
1002 convergeephemerons(g); in atomic()
1005 clearvalues(g, g->weak, NULL); in atomic()
1006 clearvalues(g, g->allweak, NULL); in atomic()
1007 origweak = g->weak; origall = g->allweak; in atomic()
1008 work += g->GCmemtrav; /* stop counting (objects being finalized) */ in atomic()
1009 separatetobefnz(g, 0); /* separate objects to be finalized */ in atomic()
1010 g->gcfinnum = 1; /* there may be objects to be finalized */ in atomic()
1011 markbeingfnz(g); /* mark objects that will be finalized */ in atomic()
1012 propagateall(g); /* remark, to propagate 'resurrection' */ in atomic()
1013 g->GCmemtrav = 0; /* restart counting */ in atomic()
1014 convergeephemerons(g); in atomic()
1017 clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */ in atomic()
1018 clearkeys(g, g->allweak, NULL); /* clear keys from all 'allweak' tables */ in atomic()
1020 clearvalues(g, g->weak, origweak); in atomic()
1021 clearvalues(g, g->allweak, origall); in atomic()
1022 luaS_clearcache(g); in atomic()
1023 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ in atomic()
1024 work += g->GCmemtrav; /* complete counting */ in atomic()
1029 static lu_mem sweepstep (lua_State *L, global_State *g, in sweepstep() argument
1031 if (g->sweepgc) { in sweepstep()
1032 l_mem olddebt = g->GCdebt; in sweepstep()
1033 g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX); in sweepstep()
1034 g->GCestimate += g->GCdebt - olddebt; /* update estimate */ in sweepstep()
1035 if (g->sweepgc) /* is there still something to sweep? */ in sweepstep()
1039 g->gcstate = nextstate; in sweepstep()
1040 g->sweepgc = nextlist; in sweepstep()
1046 global_State *g = G(L); in singlestep() local
1047 switch (g->gcstate) { in singlestep()
1049 g->GCmemtrav = g->strt.size * sizeof(GCObject*); in singlestep()
1050 restartcollection(g); in singlestep()
1051 g->gcstate = GCSpropagate; in singlestep()
1052 return g->GCmemtrav; in singlestep()
1055 g->GCmemtrav = 0; in singlestep()
1056 lua_assert(g->gray); in singlestep()
1057 propagatemark(g); in singlestep()
1058 if (g->gray == NULL) /* no more gray objects? */ in singlestep()
1059 g->gcstate = GCSatomic; /* finish propagate phase */ in singlestep()
1060 return g->GCmemtrav; /* memory traversed in this step */ in singlestep()
1064 propagateall(g); /* make sure gray list is empty */ in singlestep()
1067 g->GCestimate = gettotalbytes(g); /* first estimate */; in singlestep()
1071 return sweepstep(L, g, GCSswpfinobj, &g->finobj); in singlestep()
1074 return sweepstep(L, g, GCSswptobefnz, &g->tobefnz); in singlestep()
1077 return sweepstep(L, g, GCSswpend, NULL); in singlestep()
1080 makewhite(g, g->mainthread); /* sweep main thread */ in singlestep()
1081 checkSizes(L, g); in singlestep()
1082 g->gcstate = GCScallfin; in singlestep()
1086 if (g->tobefnz && g->gckind != KGC_EMERGENCY) { in singlestep()
1091 g->gcstate = GCSpause; /* finish collection */ in singlestep()
1105 global_State *g = G(L); in luaC_runtilstate() local
1106 while (!testbit(statesmask, g->gcstate)) in luaC_runtilstate()
1115 static l_mem getdebt (global_State *g) { in getdebt() argument
1116 l_mem debt = g->GCdebt; in getdebt()
1117 int stepmul = g->gcstepmul; in getdebt()
1130 global_State *g = G(L); in luaC_step() local
1131 l_mem debt = getdebt(g); /* GC deficit (be paid now) */ in luaC_step()
1132 if (!g->gcrunning) { /* not running? */ in luaC_step()
1133 luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */ in luaC_step()
1138 debt -= work; in luaC_step()
1139 } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); in luaC_step()
1140 if (g->gcstate == GCSpause) in luaC_step()
1141 setpause(g); /* pause until next cycle */ in luaC_step()
1143 debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */ in luaC_step()
1144 luaE_setdebt(g, debt); in luaC_step()
1160 global_State *g = G(L); in luaC_fullgc() local
1161 lua_assert(g->gckind == KGC_NORMAL); in luaC_fullgc()
1162 if (isemergency) g->gckind = KGC_EMERGENCY; /* set flag */ in luaC_fullgc()
1163 if (keepinvariant(g)) { /* black objects? */ in luaC_fullgc()
1171 lua_assert(g->GCestimate == gettotalbytes(g)); in luaC_fullgc()
1173 g->gckind = KGC_NORMAL; in luaC_fullgc()
1174 setpause(g); in luaC_fullgc()