MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / atomic

Function atomic

xrepo/packages/l/lua/port/lua/src/lgc.c:1518–1558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 4

youngcollectionFunction · 0.70
entergenFunction · 0.70
stepgenfullFunction · 0.70
singlestepFunction · 0.70

Calls 9

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

Tested by

no test coverage detected