MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / singlestep

Function singlestep

other_src/lua/src/lgc.cpp:557–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555
556
557static l_mem singlestep (lua_State *L) {
558 global_State *g = G(L);
559 /*lua_checkmemory(L);*/
560 switch (g->gcstate) {
561 case GCSpause: {
562 markroot(L); /* start a new collection */
563 return 0;
564 }
565 case GCSpropagate: {
566 if (g->gray)
567 return propagatemark(g);
568 else { /* no more `gray' objects */
569 atomic(L); /* finish mark phase */
570 return 0;
571 }
572 }
573 case GCSsweepstring: {
574 lu_mem old = g->totalbytes;
575 sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
576 if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
577 g->gcstate = GCSsweep; /* end sweep-string phase */
578 lua_assert(old >= g->totalbytes);
579 g->estimate -= old - g->totalbytes;
580 return GCSWEEPCOST;
581 }
582 case GCSsweep: {
583 lu_mem old = g->totalbytes;
584 g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
585 if (*g->sweepgc == NULL) { /* nothing more to sweep? */
586 checkSizes(L);
587 g->gcstate = GCSfinalize; /* end sweep phase */
588 }
589 lua_assert(old >= g->totalbytes);
590 g->estimate -= old - g->totalbytes;
591 return GCSWEEPMAX*GCSWEEPCOST;
592 }
593 case GCSfinalize: {
594 if (g->tmudata) {
595 GCTM(L);
596 if (g->estimate > GCFINALIZECOST)
597 g->estimate -= GCFINALIZECOST;
598 return GCFINALIZECOST;
599 }
600 else {
601 g->gcstate = GCSpause; /* end collection */
602 g->gcdept = 0;
603 return 0;
604 }
605 }
606 default: lua_assert(0); return 0;
607 }
608}
609
610
611void luaC_step (lua_State *L) {

Callers 2

luaC_stepFunction · 0.70
luaC_fullgcFunction · 0.70

Calls 6

markrootFunction · 0.70
propagatemarkFunction · 0.70
atomicFunction · 0.70
sweeplistFunction · 0.70
checkSizesFunction · 0.70
GCTMFunction · 0.70

Tested by

no test coverage detected