MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / lua_checkmemory

Function lua_checkmemory

Dependencies/lua/src/ltests.c:626–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624
625
626int lua_checkmemory (lua_State *L) {
627 global_State *g = G(L);
628 GCObject *o;
629 int maybedead;
630 lu_mem totalin; /* total of objects that are in gray lists */
631 lu_mem totalshould; /* total of objects that should be in gray lists */
632 if (keepinvariant(g)) {
633 assert(!iswhite(g->mainthread));
634 assert(!iswhite(gcvalue(&g->l_registry)));
635 }
636 assert(!isdead(g, gcvalue(&g->l_registry)));
637 assert(g->sweepgc == NULL || issweepphase(g));
638 totalin = checkgrays(g);
639
640 /* check 'fixedgc' list */
641 for (o = g->fixedgc; o != NULL; o = o->next) {
642 assert(o->tt == LUA_VSHRSTR && isgray(o) && getage(o) == G_OLD);
643 }
644
645 /* check 'allgc' list */
646 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc);
647 totalshould = checklist(g, maybedead, 0, g->allgc,
648 g->survival, g->old1, g->reallyold);
649
650 /* check 'finobj' list */
651 totalshould += checklist(g, 0, 1, g->finobj,
652 g->finobjsur, g->finobjold1, g->finobjrold);
653
654 /* check 'tobefnz' list */
655 for (o = g->tobefnz; o != NULL; o = o->next) {
656 checkobject(g, o, 0, G_NEW);
657 incifingray(g, o, &totalshould);
658 assert(tofinalize(o));
659 assert(o->tt == LUA_VUSERDATA || o->tt == LUA_VTABLE);
660 }
661 if (keepinvariant(g))
662 assert(totalin == totalshould);
663 return 0;
664}
665
666/* }====================================================== */
667

Callers

nothing calls this directly

Calls 4

checkgraysFunction · 0.85
checklistFunction · 0.85
checkobjectFunction · 0.85
incifingrayFunction · 0.85

Tested by

no test coverage detected