MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / atomic

Function atomic

3rd/lua-5.4.3/src/lgc.c:1516–1556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1514
1515
1516static lu_mem atomic (lua_State *L) {
1517 global_State *g = G(L);
1518 lu_mem work = 0;
1519 GCObject *origweak, *origall;
1520 GCObject *grayagain = g->grayagain; /* save original list */
1521 g->grayagain = NULL;
1522 lua_assert(g->ephemeron == NULL && g->weak == NULL);
1523 lua_assert(!iswhite(g->mainthread));
1524 g->gcstate = GCSatomic;
1525 markobject(g, L); /* mark running thread */
1526 /* registry and global metatables may be changed by API */
1527 markvalue(g, &g->l_registry);
1528 markmt(g); /* mark global metatables */
1529 work += propagateall(g); /* empties 'gray' list */
1530 /* remark occasional upvalues of (maybe) dead threads */
1531 work += remarkupvals(g);
1532 work += propagateall(g); /* propagate changes */
1533 g->gray = grayagain;
1534 work += propagateall(g); /* traverse 'grayagain' list */
1535 convergeephemerons(g);
1536 /* at this point, all strongly accessible objects are marked. */
1537 /* Clear values from weak tables, before checking finalizers */
1538 clearbyvalues(g, g->weak, NULL);
1539 clearbyvalues(g, g->allweak, NULL);
1540 origweak = g->weak; origall = g->allweak;
1541 separatetobefnz(g, 0); /* separate objects to be finalized */
1542 work += markbeingfnz(g); /* mark objects that will be finalized */
1543 work += propagateall(g); /* remark, to propagate 'resurrection' */
1544 convergeephemerons(g);
1545 /* at this point, all resurrected objects are marked. */
1546 /* remove dead objects from weak tables */
1547 clearbykeys(g, g->ephemeron); /* clear keys from all ephemeron tables */
1548 clearbykeys(g, g->allweak); /* clear keys from all 'allweak' tables */
1549 /* clear values from resurrected weak tables */
1550 clearbyvalues(g, g->weak, origweak);
1551 clearbyvalues(g, g->allweak, origall);
1552 luaS_clearcache(g);
1553 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
1554 lua_assert(g->gray == NULL);
1555 return work; /* estimate of slots marked by 'atomic' */
1556}
1557
1558
1559static int sweepstep (lua_State *L, global_State *g,

Callers 4

youngcollectionFunction · 0.85
entergenFunction · 0.85
stepgenfullFunction · 0.85
singlestepFunction · 0.85

Calls 9

markmtFunction · 0.85
propagateallFunction · 0.85
remarkupvalsFunction · 0.85
convergeephemeronsFunction · 0.85
clearbyvaluesFunction · 0.85
separatetobefnzFunction · 0.85
markbeingfnzFunction · 0.85
clearbykeysFunction · 0.85
luaS_clearcacheFunction · 0.85

Tested by

no test coverage detected