diff options
author | Mike Pall <mike> | 2010-02-13 04:51:56 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-02-13 04:51:56 +0100 |
commit | c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b (patch) | |
tree | 8c0ffe2086ab0b032ed8e9f92ae6fb9d4d040d66 /src/lj_state.c | |
parent | 4f8d7be8ea8a103f4d9046188d6005740b74f3d4 (diff) | |
download | luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.tar.gz luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.tar.bz2 luajit-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.zip |
Major redesign of function call handling.
Drop call gates. Use function headers, dispatched like bytecodes.
Emit BC_FUNCF/BC_FUNCV bytecode at PC 0 for all Lua functions.
C functions and ASM fast functions get extra bytecodes.
Modify internal calling convention: new base in BASE (formerly in RA).
Can now use better C function wrapper semantics (dynamic on/off).
Prerequisite for call hooks with zero-overhead if disabled.
Prerequisite for compiling recursive calls.
Prerequisite for efficient 32/64 bit prototype guards.
Diffstat (limited to 'src/lj_state.c')
-rw-r--r-- | src/lj_state.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lj_state.c b/src/lj_state.c index 69f182ed..8f8be97b 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -37,8 +37,8 @@ | |||
37 | ** Calls to metamethods store their arguments beyond the current top | 37 | ** Calls to metamethods store their arguments beyond the current top |
38 | ** without checking for the stack limit. This avoids stack resizes which | 38 | ** without checking for the stack limit. This avoids stack resizes which |
39 | ** would invalidate passed TValue pointers. The stack check is performed | 39 | ** would invalidate passed TValue pointers. The stack check is performed |
40 | ** later by the call gate. This can safely resize the stack or raise an | 40 | ** later by the function header. This can safely resize the stack or raise |
41 | ** error. Thus we need some extra slots beyond the current stack limit. | 41 | ** an error. Thus we need some extra slots beyond the current stack limit. |
42 | ** | 42 | ** |
43 | ** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus | 43 | ** Most metamethods need 4 slots above top (cont, mobj, arg1, arg2) plus |
44 | ** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 | 44 | ** one extra slot if mobj is not a function. Only lj_meta_tset needs 5 |
@@ -119,8 +119,6 @@ static void stack_init(lua_State *L1, lua_State *L) | |||
119 | 119 | ||
120 | /* -- State handling ------------------------------------------------------ */ | 120 | /* -- State handling ------------------------------------------------------ */ |
121 | 121 | ||
122 | #define GG_SIZE (sizeof(GG_State)+(BC__MAX*2)*sizeof(ASMFunction)) | ||
123 | |||
124 | /* Open parts that may cause memory-allocation errors. */ | 122 | /* Open parts that may cause memory-allocation errors. */ |
125 | static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) | 123 | static TValue *cpluaopen(lua_State *L, lua_CFunction dummy, void *ud) |
126 | { | 124 | { |
@@ -156,8 +154,8 @@ static void close_state(lua_State *L) | |||
156 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); | 154 | lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef); |
157 | lj_str_freebuf(g, &g->tmpbuf); | 155 | lj_str_freebuf(g, &g->tmpbuf); |
158 | lj_mem_freevec(g, L->stack, L->stacksize, TValue); | 156 | lj_mem_freevec(g, L->stack, L->stacksize, TValue); |
159 | lua_assert(g->gc.total == GG_SIZE); | 157 | lua_assert(g->gc.total == sizeof(GG_State)); |
160 | g->allocf(g->allocd, G2GG(g), GG_SIZE, 0); | 158 | g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0); |
161 | } | 159 | } |
162 | } | 160 | } |
163 | 161 | ||
@@ -167,7 +165,7 @@ lua_State *lj_state_newstate(lua_Alloc f, void *ud) | |||
167 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | 165 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) |
168 | #endif | 166 | #endif |
169 | { | 167 | { |
170 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, GG_SIZE)); | 168 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State))); |
171 | lua_State *L = &GG->L; | 169 | lua_State *L = &GG->L; |
172 | global_State *g = &GG->g; | 170 | global_State *g = &GG->g; |
173 | if (GG == NULL || !checkptr32(GG)) return NULL; | 171 | if (GG == NULL || !checkptr32(GG)) return NULL; |
@@ -190,7 +188,7 @@ LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | |||
190 | g->gc.state = GCSpause; | 188 | g->gc.state = GCSpause; |
191 | setgcref(g->gc.root, obj2gco(L)); | 189 | setgcref(g->gc.root, obj2gco(L)); |
192 | g->gc.sweep = &g->gc.root; | 190 | g->gc.sweep = &g->gc.root; |
193 | g->gc.total = GG_SIZE; | 191 | g->gc.total = sizeof(GG_State); |
194 | g->gc.pause = LUAI_GCPAUSE; | 192 | g->gc.pause = LUAI_GCPAUSE; |
195 | g->gc.stepmul = LUAI_GCMUL; | 193 | g->gc.stepmul = LUAI_GCMUL; |
196 | lj_dispatch_init((GG_State *)L); | 194 | lj_dispatch_init((GG_State *)L); |