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.
This commit is contained in:
11
src/lj_lib.c
11
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
|
||||
|
||||
Reference in New Issue
Block a user