Merge branch 'master' into v2.1

This commit is contained in:
Mike Pall 2013-10-14 19:34:06 +02:00
commit d0b48ec996
4 changed files with 18 additions and 1 deletions

View File

@ -493,6 +493,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);
@ -629,6 +630,9 @@ static size_t gc_onestep(lua_State *L)
lj_str_resize(L, g->strmask >> 1); /* Shrink string table. */
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;
@ -647,6 +651,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;

View File

@ -494,7 +494,7 @@ typedef struct GCState {
MSize threshold; /* Memory threshold. */
uint8_t currentwhite; /* Current white color. */
uint8_t state; /* GC state. */
uint8_t unused1;
uint8_t nocdatafin; /* No cdata finalizer called. */
uint8_t unused2;
MSize sweepstr; /* Sweep position in string table. */
GCRef root; /* List of all collectable objects. */

View File

@ -357,6 +357,13 @@ static void rehashtab(lua_State *L, GCtab *t, cTValue *ek)
resizetab(L, t, asize, hsize2hbits(total));
}
#if LJ_HASFFI
void lj_tab_rehash(lua_State *L, GCtab *t)
{
rehashtab(L, t, niltv(L));
}
#endif
void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize)
{
resizetab(L, t, nasize+1, t->hmask > 0 ? lj_fls(t->hmask)+1 : 0);

View File

@ -40,6 +40,9 @@ LJ_FUNC GCtab * LJ_FASTCALL lj_tab_new1(lua_State *L, uint32_t ahsize);
#endif
LJ_FUNCA GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt);
LJ_FUNC void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t);
#if LJ_HASFFI
LJ_FUNC void lj_tab_rehash(lua_State *L, GCtab *t);
#endif
LJ_FUNCA void lj_tab_reasize(lua_State *L, GCtab *t, uint32_t nasize);
/* Caveat: all getters except lj_tab_get() can return NULL! */