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

Function singlestep

third-party/lua-5.4.6/src/lgc.c:1585–1645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1583
1584
1585static lu_mem singlestep (lua_State *L) {
1586 global_State *g = G(L);
1587 lu_mem work;
1588 lua_assert(!g->gcstopem); /* collector is not reentrant */
1589 g->gcstopem = 1; /* no emergency collections while collecting */
1590 switch (g->gcstate) {
1591 case GCSpause: {
1592 restartcollection(g);
1593 g->gcstate = GCSpropagate;
1594 work = 1;
1595 break;
1596 }
1597 case GCSpropagate: {
1598 if (g->gray == NULL) { /* no more gray objects? */
1599 g->gcstate = GCSenteratomic; /* finish propagate phase */
1600 work = 0;
1601 }
1602 else
1603 work = propagatemark(g); /* traverse one gray object */
1604 break;
1605 }
1606 case GCSenteratomic: {
1607 work = atomic(L); /* work is what was traversed by 'atomic' */
1608 entersweep(L);
1609 g->GCestimate = gettotalbytes(g); /* first estimate */
1610 break;
1611 }
1612 case GCSswpallgc: { /* sweep "regular" objects */
1613 work = sweepstep(L, g, GCSswpfinobj, &g->finobj);
1614 break;
1615 }
1616 case GCSswpfinobj: { /* sweep objects with finalizers */
1617 work = sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
1618 break;
1619 }
1620 case GCSswptobefnz: { /* sweep objects to be finalized */
1621 work = sweepstep(L, g, GCSswpend, NULL);
1622 break;
1623 }
1624 case GCSswpend: { /* finish sweeps */
1625 checkSizes(L, g);
1626 g->gcstate = GCScallfin;
1627 work = 0;
1628 break;
1629 }
1630 case GCScallfin: { /* call remaining finalizers */
1631 if (g->tobefnz && !g->gcemergency) {
1632 g->gcstopem = 0; /* ok collections during finalizers */
1633 work = runafewfinalizers(L, GCFINMAX) * GCFINALIZECOST;
1634 }
1635 else { /* emergency mode or no more finalizers */
1636 g->gcstate = GCSpause; /* finish collection */
1637 work = 0;
1638 }
1639 break;
1640 }
1641 default: lua_assert(0); return 0;
1642 }

Callers 2

luaC_runtilstateFunction · 0.70
incstepFunction · 0.70

Calls 7

restartcollectionFunction · 0.70
propagatemarkFunction · 0.70
atomicFunction · 0.70
entersweepFunction · 0.70
sweepstepFunction · 0.70
checkSizesFunction · 0.70
runafewfinalizersFunction · 0.70

Tested by

no test coverage detected