** Performs a basic incremental step. The step size is ** converted from bytes to "units of work"; then the function loops ** running single steps until adding that many units of work or ** finishing a cycle (pause state). Finally, it sets the debt that ** controls when next step will be performed. */
| 1708 | ** controls when next step will be performed. |
| 1709 | */ |
| 1710 | static void incstep (lua_State *L, global_State *g) { |
| 1711 | l_mem stepsize = applygcparam(g, STEPSIZE, 100); |
| 1712 | l_mem work2do = applygcparam(g, STEPMUL, stepsize / cast_int(sizeof(void*))); |
| 1713 | l_mem stres; |
| 1714 | int fast = (work2do == 0); /* special case: do a full collection */ |
| 1715 | do { /* repeat until enough work */ |
| 1716 | stres = singlestep(L, fast); /* perform one single step */ |
| 1717 | if (stres == step2minor) /* returned to minor collections? */ |
| 1718 | return; /* nothing else to be done here */ |
| 1719 | else if (stres == step2pause || (stres == atomicstep && !fast)) |
| 1720 | break; /* end of cycle or atomic */ |
| 1721 | else |
| 1722 | work2do -= stres; |
| 1723 | } while (fast || work2do > 0); |
| 1724 | if (g->gcstate == GCSpause) |
| 1725 | setpause(g); /* pause until next cycle */ |
| 1726 | else |
| 1727 | luaE_setdebt(g, stepsize); |
| 1728 | } |
| 1729 | |
| 1730 | |
| 1731 | #if !defined(luai_tracegc) |
no test coverage detected