MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / atomic

Function atomic

src/Chain/libraries/glua/lgc.cpp:985–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

983
984
985static l_mem atomic(lua_State *L) {
986 global_State *g = G(L);
987 l_mem work;
988 GCObject *origweak, *origall;
989 GCObject *grayagain = g->grayagain; /* save original list */
990 lua_assert(g->ephemeron == nullptr && g->weak == nullptr);
991 lua_assert(!iswhite(g->mainthread));
992 g->gcstate = GCSinsideatomic;
993 g->GCmemtrav = 0; /* start counting work */
994 markobject(g, L); /* mark running thread */
995 /* registry and global metatables may be changed by API */
996 markvalue(g, &g->l_registry);
997 markmt(g); /* mark global metatables */
998 /* remark occasional upvalues of (maybe) dead threads */
999 remarkupvals(g);
1000 propagateall(g); /* propagate changes */
1001 work = g->GCmemtrav; /* stop counting (do not recount 'grayagain') */
1002 g->gray = grayagain;
1003 propagateall(g); /* traverse 'grayagain' list */
1004 g->GCmemtrav = 0; /* restart counting */
1005 convergeephemerons(g);
1006 /* at this point, all strongly accessible objects are marked. */
1007 /* Clear values from weak tables, before checking finalizers */
1008 clearvalues(g, g->weak, nullptr);
1009 clearvalues(g, g->allweak, nullptr);
1010 origweak = g->weak; origall = g->allweak;
1011 work += g->GCmemtrav; /* stop counting (objects being finalized) */
1012 separatetobefnz(g, 0); /* separate objects to be finalized */
1013 g->gcfinnum = 1; /* there may be objects to be finalized */
1014 markbeingfnz(g); /* mark objects that will be finalized */
1015 propagateall(g); /* remark, to propagate 'resurrection' */
1016 g->GCmemtrav = 0; /* restart counting */
1017 convergeephemerons(g);
1018 /* at this point, all resurrected objects are marked. */
1019 /* remove dead objects from weak tables */
1020 clearkeys(g, g->ephemeron, nullptr); /* clear keys from all ephemeron tables */
1021 clearkeys(g, g->allweak, nullptr); /* clear keys from all 'allweak' tables */
1022 /* clear values from resurrected weak tables */
1023 clearvalues(g, g->weak, origweak);
1024 clearvalues(g, g->allweak, origall);
1025 luaS_clearcache(g);
1026 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
1027 work += g->GCmemtrav; /* complete counting */
1028 return work; /* estimate of memory marked by 'atomic' */
1029}
1030
1031
1032static lu_mem sweepstep(lua_State *L, global_State *g,

Callers 1

singlestepFunction · 0.85

Calls 9

markmtFunction · 0.85
remarkupvalsFunction · 0.85
propagateallFunction · 0.85
convergeephemeronsFunction · 0.85
clearvaluesFunction · 0.85
separatetobefnzFunction · 0.85
markbeingfnzFunction · 0.85
clearkeysFunction · 0.85
luaS_clearcacheFunction · 0.85

Tested by

no test coverage detected