MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / singlestep

Function singlestep

extlibs/lua/src/lgc.c:1476–1524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1474
1475
1476static lu_mem singlestep (lua_State *L) {
1477 global_State *g = G(L);
1478 switch (g->gcstate) {
1479 case GCSpause: {
1480 restartcollection(g);
1481 g->gcstate = GCSpropagate;
1482 return 1;
1483 }
1484 case GCSpropagate: {
1485 if (g->gray == NULL) { /* no more gray objects? */
1486 g->gcstate = GCSenteratomic; /* finish propagate phase */
1487 return 0;
1488 }
1489 else
1490 return propagatemark(g); /* traverse one gray object */
1491 }
1492 case GCSenteratomic: {
1493 lu_mem work = atomic(L); /* work is what was traversed by 'atomic' */
1494 entersweep(L);
1495 g->GCestimate = gettotalbytes(g); /* first estimate */;
1496 return work;
1497 }
1498 case GCSswpallgc: { /* sweep "regular" objects */
1499 return sweepstep(L, g, GCSswpfinobj, &g->finobj);
1500 }
1501 case GCSswpfinobj: { /* sweep objects with finalizers */
1502 return sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
1503 }
1504 case GCSswptobefnz: { /* sweep objects to be finalized */
1505 return sweepstep(L, g, GCSswpend, NULL);
1506 }
1507 case GCSswpend: { /* finish sweeps */
1508 checkSizes(L, g);
1509 g->gcstate = GCScallfin;
1510 return 0;
1511 }
1512 case GCScallfin: { /* call remaining finalizers */
1513 if (g->tobefnz && !g->gcemergency) {
1514 int n = runafewfinalizers(L, GCFINMAX);
1515 return n * GCFINALIZECOST;
1516 }
1517 else { /* emergency mode or no more finalizers */
1518 g->gcstate = GCSpause; /* finish collection */
1519 return 0;
1520 }
1521 }
1522 default: lua_assert(0); return 0;
1523 }
1524}
1525
1526
1527/*

Callers 2

luaC_runtilstateFunction · 0.85
incstepFunction · 0.85

Calls 7

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

Tested by

no test coverage detected