lim = (GCSTEPSIZE/100) * g->gc.stepmul;
if (lim == 0)
lim = LJ_MAX_MEM;
- g->gc.debt += g->gc.total - g->gc.threshold;
+ if (g->gc.total > g->gc.threshold)
+ g->gc.debt += g->gc.total - g->gc.threshold;
do {
lim -= (MSize)gc_onestep(L);
if (g->gc.state == GCSpause) {
setcframe_pc(cf, pc);
if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) {
if (!(G(L)->hookmask & HOOK_GC))
- lj_gc_check(L); /* Exited because of GC: drive GC forward. */
+ lj_gc_step(L); /* Exited because of GC: drive GC forward. */
} else {
trace_hotside(J, pc);
}