diff options
Diffstat (limited to '3rdparty/lua/src/lj_gc.c')
-rw-r--r-- | 3rdparty/lua/src/lj_gc.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/3rdparty/lua/src/lj_gc.c b/3rdparty/lua/src/lj_gc.c index 79f8b72..b498aba 100644 --- a/3rdparty/lua/src/lj_gc.c +++ b/3rdparty/lua/src/lj_gc.c @@ -1,6 +1,6 @@ /* ** Garbage collector. -** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h +** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h ** ** Major portions taken verbatim or adapted from the Lua interpreter. ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h @@ -501,6 +501,7 @@ static void gc_finalize(lua_State *L) setcdataV(L, &tmp, gco2cd(o)); tv = lj_tab_set(L, ctype_ctsG(g)->finalizer, &tmp); if (!tvisnil(tv)) { + g->gc.nocdatafin = 0; copyTV(L, &tmp, tv); setnilV(tv); /* Clear entry in finalizer table. */ gc_call_finalizer(g, L, &tmp, o); @@ -630,17 +631,20 @@ static size_t gc_onestep(lua_State *L) case GCSsweep: { MSize old = g->gc.total; setmref(g->gc.sweep, gc_sweep(g, mref(g->gc.sweep, GCRef), GCSWEEPMAX)); + lua_assert(old >= g->gc.total); + g->gc.estimate -= old - g->gc.total; if (gcref(*mref(g->gc.sweep, GCRef)) == NULL) { gc_shrink(g, L); if (gcref(g->gc.mmudata)) { /* Need any finalizations? */ g->gc.state = GCSfinalize; +#if LJ_HASFFI + g->gc.nocdatafin = 1; +#endif } else { /* Otherwise skip this phase to help the JIT. */ g->gc.state = GCSpause; /* End of GC cycle. */ g->gc.debt = 0; } } - lua_assert(old >= g->gc.total); - g->gc.estimate -= old - g->gc.total; return GCSWEEPMAX*GCSWEEPCOST; } case GCSfinalize: @@ -652,6 +656,9 @@ static size_t gc_onestep(lua_State *L) g->gc.estimate -= GCFINALIZECOST; return GCFINALIZECOST; } +#if LJ_HASFFI + if (!g->gc.nocdatafin) lj_tab_rehash(L, ctype_ctsG(g)->finalizer); +#endif g->gc.state = GCSpause; /* End of GC cycle. */ g->gc.debt = 0; return 0; @@ -671,7 +678,8 @@ int LJ_FASTCALL lj_gc_step(lua_State *L) 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) { @@ -682,12 +690,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. */ |