Move dispatch tables out of GG_State struct.

This commit is contained in:
Mike Pall
2010-02-11 16:21:18 +01:00
parent 565eb39574
commit b2067236c5
10 changed files with 45 additions and 43 deletions

View File

@@ -119,6 +119,8 @@ static void stack_init(lua_State *L1, lua_State *L)
/* -- State handling ------------------------------------------------------ */
#define GG_SIZE (sizeof(GG_State)+(BC__MAX*2)*sizeof(ASMFunction))
/* Open parts that may cause memory-allocation errors. */
static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud)
{
@@ -154,8 +156,8 @@ static void close_state(lua_State *L)
lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
lj_str_freebuf(g, &g->tmpbuf);
lj_mem_freevec(g, L->stack, L->stacksize, TValue);
lua_assert(g->gc.total == sizeof(GG_State));
g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
lua_assert(g->gc.total == GG_SIZE);
g->allocf(g->allocd, G2GG(g), GG_SIZE, 0);
}
}
@@ -165,7 +167,7 @@ lua_State *lj_state_newstate(lua_Alloc f, void *ud)
LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
#endif
{
GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State)));
GG_State *GG = cast(GG_State *, f(ud, NULL, 0, GG_SIZE));
lua_State *L = &GG->L;
global_State *g = &GG->g;
if (GG == NULL || !checkptr32(GG)) return NULL;
@@ -188,7 +190,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud)
g->gc.state = GCSpause;
setgcref(g->gc.root, obj2gco(L));
g->gc.sweep = &g->gc.root;
g->gc.total = sizeof(GG_State);
g->gc.total = GG_SIZE;
g->gc.pause = LUAI_GCPAUSE;
g->gc.stepmul = LUAI_GCMUL;
lj_dispatch_init((GG_State *)L);