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:
Mike Pall
2010-02-13 04:51:56 +01:00
parent 4f8d7be8ea
commit c93138b59e
34 changed files with 4410 additions and 4264 deletions

View File

@@ -152,7 +152,7 @@ static const char *getobjname(GCproto *pt, const BCIns *ip, BCReg slot,
restart:
lname = getvarname(pt, proto_bcpos(pt, ip), slot);
if (lname != NULL) { *name = lname; return "local"; }
while (--ip >= proto_bc(pt)) {
while (--ip > proto_bc(pt)) {
BCIns ins = *ip;
BCOp op = bc_op(ins);
BCReg ra = bc_a(ins);
@@ -222,11 +222,7 @@ void lj_err_pushloc(lua_State *L, GCproto *pt, BCPos pc)
if (name) {
const char *s = strdata(name);
MSize i, len = name->len;
BCLine line;
if (pc)
line = proto_line(pt, pc-1);
else
line = pt->linedefined;
BCLine line = pc < pt->sizebc ? proto_line(pt, pc) : 0;
if (*s == '@') {
s++; len--;
for (i = len; i > 0; i--)
@@ -345,9 +341,10 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
switch (*what) {
case 'S':
if (isluafunc(fn)) {
ar->source = strdata(proto_chunkname(funcproto(fn)));
ar->linedefined = cast_int(funcproto(fn)->linedefined);
ar->lastlinedefined = cast_int(funcproto(fn)->lastlinedefined);
GCproto *pt = funcproto(fn);
ar->source = strdata(proto_chunkname(pt));
ar->linedefined = (int)proto_line(pt, 0);
ar->lastlinedefined = (int)pt->lastlinedefined;
ar->what = (ar->linedefined == 0) ? "main" : "Lua";
} else {
ar->source = "=[C]";
@@ -380,7 +377,7 @@ LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
GCproto *pt = funcproto(fn);
BCLine *lineinfo = proto_lineinfo(pt);
MSize i, szl = pt->sizebc;
for (i = 0; i < szl; i++)
for (i = 1; i < szl; i++)
setboolV(lj_tab_setint(L, t, lineinfo[i]), 1);
settabV(L, L->top, t);
} else {