瀏覽代碼

Fix GC steps threshold handling when called by JIT-compiled code.

Thanks to Cheng, Long.
Mike Pall 12 年之前
父節點
當前提交
7b4d5306c7
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 4 2
      src/lj_gc.c
  2. 1 1
      src/lj_trace.c

+ 4 - 2
src/lj_gc.c

@@ -689,12 +689,14 @@ int LJ_FASTCALL lj_gc_step(lua_State *L)
   } while ((int32_t)lim > 0);
   if (g->gc.debt < GCSTEPSIZE) {
     g->gc.threshold = g->gc.total + GCSTEPSIZE;
+    g->vmstate = ostate;
+    return 1;
   } else {
     g->gc.debt -= GCSTEPSIZE;
     g->gc.threshold = g->gc.total;
+    g->vmstate = ostate;
+    return 0;
   }
-  g->vmstate = ostate;
-  return 0;
 }
 
 /* Ditto, but fix the stack top first. */

+ 1 - 1
src/lj_trace.c

@@ -778,7 +778,7 @@ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr)
   setcframe_pc(cf, pc);
   if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) {
     if (!(G(L)->hookmask & HOOK_GC))
-      lj_gc_step(L);  /* Exited because of GC: drive GC forward. */
+      lj_gc_check(L);  /* Exited because of GC: drive GC forward. */
   } else {
     trace_hotside(J, pc);
   }