aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/lapi.c b/lapi.c
index 93695144..f807bd4b 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1191,25 +1191,11 @@ LUA_API int lua_gc (lua_State *L, int what, ...) {
1191 break; 1191 break;
1192 } 1192 }
1193 case LUA_GCSTEP: { 1193 case LUA_GCSTEP: {
1194 int todo = va_arg(argp, int); /* work to be done */
1195 int didsomething = 0;
1196 lu_byte oldstp = g->gcstp; 1194 lu_byte oldstp = g->gcstp;
1197 g->gcstp = 0; /* allow GC to run (other bits must be zero here) */ 1195 g->gcstp = 0; /* allow GC to run (other bits must be zero here) */
1198 if (todo == 0) 1196 luaC_step(L); /* run one basic step */
1199 todo = 1 << g->gcstepsize; /* standard step size */
1200 while (todo >= g->GCdebt) { /* enough to run a step? */
1201 todo -= g->GCdebt; /* decrement 'todo' */
1202 luaC_step(L); /* run one basic step */
1203 didsomething = 1;
1204 if (g->gckind == KGC_GEN) /* minor collections? */
1205 todo = 0; /* doesn't make sense to repeat in this case */
1206 else if (g->gcstate == GCSpause)
1207 break; /* don't run more than one cycle */
1208 }
1209 /* remove remaining 'todo' from total debt */
1210 luaE_setdebt(g, g->GCdebt - todo);
1211 g->gcstp = oldstp; /* restore previous state */ 1197 g->gcstp = oldstp; /* restore previous state */
1212 if (didsomething && g->gcstate == GCSpause) /* end of cycle? */ 1198 if (g->gcstate == GCSpause) /* end of cycle? */
1213 res = 1; /* signal it */ 1199 res = 1; /* signal it */
1214 break; 1200 break;
1215 } 1201 }