MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / atomic

Function atomic

third-party/lua-5.5.0/src/lgc.c:1543–1581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1541
1542
1543static void atomic (lua_State *L) {
1544 global_State *g = G(L);
1545 GCObject *origweak, *origall;
1546 GCObject *grayagain = g->grayagain; /* save original list */
1547 g->grayagain = NULL;
1548 lua_assert(g->ephemeron == NULL && g->weak == NULL);
1549 lua_assert(!iswhite(mainthread(g)));
1550 g->gcstate = GCSatomic;
1551 markobject(g, L); /* mark running thread */
1552 /* registry and global metatables may be changed by API */
1553 markvalue(g, &g->l_registry);
1554 markmt(g); /* mark global metatables */
1555 propagateall(g); /* empties 'gray' list */
1556 /* remark occasional upvalues of (maybe) dead threads */
1557 remarkupvals(g);
1558 propagateall(g); /* propagate changes */
1559 g->gray = grayagain;
1560 propagateall(g); /* traverse 'grayagain' list */
1561 convergeephemerons(g);
1562 /* at this point, all strongly accessible objects are marked. */
1563 /* Clear values from weak tables, before checking finalizers */
1564 clearbyvalues(g, g->weak, NULL);
1565 clearbyvalues(g, g->allweak, NULL);
1566 origweak = g->weak; origall = g->allweak;
1567 separatetobefnz(g, 0); /* separate objects to be finalized */
1568 markbeingfnz(g); /* mark objects that will be finalized */
1569 propagateall(g); /* remark, to propagate 'resurrection' */
1570 convergeephemerons(g);
1571 /* at this point, all resurrected objects are marked. */
1572 /* remove dead objects from weak tables */
1573 clearbykeys(g, g->ephemeron); /* clear keys from all ephemeron */
1574 clearbykeys(g, g->allweak); /* clear keys from all 'allweak' */
1575 /* clear values from resurrected weak tables */
1576 clearbyvalues(g, g->weak, origweak);
1577 clearbyvalues(g, g->allweak, origall);
1578 luaS_clearcache(g);
1579 g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */
1580 lua_assert(g->gray == NULL);
1581}
1582
1583
1584/*

Callers 3

youngcollectionFunction · 0.70
entergenFunction · 0.70
singlestepFunction · 0.70

Calls 9

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

Tested by

no test coverage detected