** performs a basic GC step when collector is running */
| 1127 | ** performs a basic GC step when collector is running |
| 1128 | */ |
| 1129 | void luaC_step (lua_State *L) { |
| 1130 | global_State *g = G(L); |
| 1131 | l_mem debt = getdebt(g); /* GC deficit (be paid now) */ |
| 1132 | if (!g->gcrunning) { /* not running? */ |
| 1133 | luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */ |
| 1134 | return; |
| 1135 | } |
| 1136 | do { /* repeat until pause or enough "credit" (negative debt) */ |
| 1137 | lu_mem work = singlestep(L); /* perform one single step */ |
| 1138 | debt -= work; |
| 1139 | } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); |
| 1140 | if (g->gcstate == GCSpause) |
| 1141 | setpause(g); /* pause until next cycle */ |
| 1142 | else { |
| 1143 | debt = (debt / g->gcstepmul) * STEPMULADJ; /* convert 'work units' to Kb */ |
| 1144 | luaE_setdebt(g, debt); |
| 1145 | runafewfinalizers(L); |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | |
| 1150 | /* |
no test coverage detected