summaryrefslogtreecommitdiff
path: root/src/lj_lib.c
diff options
context:
space:
mode:
authorMike Pall <mike>2010-02-13 04:51:56 +0100
committerMike Pall <mike>2010-02-13 04:51:56 +0100
commitc93138b59e8f28b3d412cd7ec0c6631fd27e3e1b (patch)
tree8c0ffe2086ab0b032ed8e9f92ae6fb9d4d040d66 /src/lj_lib.c
parent4f8d7be8ea8a103f4d9046188d6005740b74f3d4 (diff)
downloadluajit2-c93138b59e8f28b3d412cd7ec0c6631fd27e3e1b.tar.gz
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_lib.c')
-rw-r--r--src/lj_lib.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lj_lib.c b/src/lj_lib.c
index de1c8646..0ba0ecb1 100644
--- a/src/lj_lib.c
+++ b/src/lj_lib.c
@@ -14,6 +14,8 @@
#include "lj_str.h"
#include "lj_tab.h"
#include "lj_func.h"
+#include "lj_bc.h"
+#include "lj_dispatch.h"
#include "lj_vm.h"
#include "lj_lib.h"
@@ -46,6 +48,7 @@ void lj_lib_register(lua_State *L, const char *libname,
GCtab *env = tabref(L->env);
GCfunc *ofn = NULL;
int ffid = *p++;
+ BCIns *bcff = &L2GG(L)->bcff[*p++];
GCtab *tab = lib_create_table(L, libname, *p++);
ptrdiff_t tpos = L->top - L->base;
@@ -68,10 +71,10 @@ void lj_lib_register(lua_State *L, const char *libname,
fn->c.ffid = (uint8_t)(ffid++);
name = (const char *)p;
p += len;
- if (tag != LIBINIT_CF) {
- fn->c.gate = makeasmfunc(p[0] + (p[1] << 8));
- p += 2;
- }
+ if (tag == LIBINIT_CF)
+ setmref(fn->c.pc, &G(L)->bc_cfunc_int);
+ else
+ setmref(fn->c.pc, bcff++);
if (tag == LIBINIT_ASM_)
fn->c.f = ofn->c.f; /* Copy handler from previous function. */
else