MCPcopy Create free account
hub / github.com/F-Stack/f-stack / atomic

Function atomic

freebsd/contrib/openzfs/module/lua/lgc.c:998–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

996
997
998static l_mem atomic (lua_State *L) {
999 global_State *g = G(L);
1000 l_mem work = -cast(l_mem, g->GCmemtrav); /* start counting work */
1001 GCObject *origweak, *origall;
1002 lua_assert(!iswhite(obj2gco(g->mainthread)));
1003 markobject(g, L); /* mark running thread */
1004 /* registry and global metatables may be changed by API */
1005 markvalue(g, &g->l_registry);
1006 markmt(g); /* mark basic metatables */
1007 /* remark occasional upvalues of (maybe) dead threads */
1008 remarkupvals(g);
1009 propagateall(g); /* propagate changes */
1010 work += g->GCmemtrav; /* stop counting (do not (re)count grays) */
1011 /* traverse objects caught by write barrier and by 'remarkupvals' */
1012 retraversegrays(g);
1013 work -= g->GCmemtrav; /* restart counting */
1014 convergeephemerons(g);
1015 /* at this point, all strongly accessible objects are marked. */
1016 /* clear values from weak tables, before checking finalizers */
1017 clearvalues(g, g->weak, NULL);
1018 clearvalues(g, g->allweak, NULL);
1019 origweak = g->weak; origall = g->allweak;
1020 work += g->GCmemtrav; /* stop counting (objects being finalized) */
1021 separatetobefnz(L, 0); /* separate objects to be finalized */
1022 markbeingfnz(g); /* mark objects that will be finalized */
1023 propagateall(g); /* remark, to propagate `preserveness' */
1024 work -= g->GCmemtrav; /* restart counting */
1025 convergeephemerons(g);
1026 /* at this point, all resurrected objects are marked. */
1027 /* remove dead objects from weak tables */
1028 clearkeys(g, g->ephemeron, NULL); /* clear keys from all ephemeron tables */
1029 clearkeys(g, g->allweak, NULL); /* clear keys from all allweak tables */
1030 /* clear values from resurrected weak tables */
1031 clearvalues(g, g->weak, origweak);
1032 clearvalues(g, g->allweak, origall);
1033 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
1034 work += g->GCmemtrav; /* complete counting */
1035 return work; /* estimate of memory marked by 'atomic' */
1036}
1037
1038
1039static lu_mem singlestep (lua_State *L) {

Callers 1

singlestepFunction · 0.70

Calls 9

retraversegraysFunction · 0.85
convergeephemeronsFunction · 0.85
clearvaluesFunction · 0.85
separatetobefnzFunction · 0.85
markbeingfnzFunction · 0.85
clearkeysFunction · 0.85
markmtFunction · 0.70
remarkupvalsFunction · 0.70
propagateallFunction · 0.70

Tested by

no test coverage detected