mirror of https://github.com/rusefi/lua.git
no more field 'base' in CallInfo (base is always equal to 'func + 1',
with old/new vararg implementation)
This commit is contained in:
parent
5c8770f896
commit
6d95de83c6
11
ldebug.c
11
ldebug.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldebug.c,v 2.124 2017/04/29 15:28:38 roberto Exp roberto $
|
||||
** $Id: ldebug.c,v 2.125 2017/05/13 13:04:33 roberto Exp roberto $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ static const char *findlocal (lua_State *L, CallInfo *ci, int n,
|
|||
const char *name = NULL;
|
||||
StkId base;
|
||||
if (isLua(ci)) {
|
||||
base = ci->u.l.base;
|
||||
base = ci->func + 1;
|
||||
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
|
||||
}
|
||||
else
|
||||
|
@ -562,8 +562,9 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
|
|||
** checks are ISO C and ensure a correct result.
|
||||
*/
|
||||
static int isinstack (CallInfo *ci, const TValue *o) {
|
||||
ptrdiff_t i = o - ci->u.l.base;
|
||||
return (0 <= i && i < (ci->top - ci->u.l.base) && ci->u.l.base + i == o);
|
||||
StkId base = ci->func + 1;
|
||||
ptrdiff_t i = o - base;
|
||||
return (0 <= i && i < (ci->top - base) && base + i == o);
|
||||
}
|
||||
|
||||
|
||||
|
@ -594,7 +595,7 @@ static const char *varinfo (lua_State *L, const TValue *o) {
|
|||
kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
|
||||
if (!kind && isinstack(ci, o)) /* no? try a register */
|
||||
kind = getobjname(ci_func(ci)->p, currentpc(ci),
|
||||
cast_int(o - ci->u.l.base), &name);
|
||||
cast_int(o - (ci->func + 1)), &name);
|
||||
}
|
||||
return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : "";
|
||||
}
|
||||
|
|
5
ldo.c
5
ldo.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldo.c,v 2.157 2016/12/13 15:52:21 roberto Exp roberto $
|
||||
** $Id: ldo.c,v 2.158 2017/05/13 12:57:20 roberto Exp roberto $
|
||||
** Stack and Call structure of Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -164,8 +164,6 @@ static void correctstack (lua_State *L, TValue *oldstack) {
|
|||
for (ci = L->ci; ci != NULL; ci = ci->previous) {
|
||||
ci->top = (ci->top - oldstack) + L->stack;
|
||||
ci->func = (ci->func - oldstack) + L->stack;
|
||||
if (isLua(ci))
|
||||
ci->u.l.base = (ci->u.l.base - oldstack) + L->stack;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,7 +422,6 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||
ci = next_ci(L); /* now 'enter' new function */
|
||||
ci->nresults = nresults;
|
||||
ci->func = func;
|
||||
ci->u.l.base = func + 1;
|
||||
L->top = ci->top = func + 1 + fsize;
|
||||
lua_assert(ci->top <= L->stack_last);
|
||||
ci->u.l.savedpc = p->code; /* starting point */
|
||||
|
|
3
lstate.h
3
lstate.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.h,v 2.139 2017/04/24 16:59:26 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 2.140 2017/05/04 13:32:01 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -96,7 +96,6 @@ typedef struct CallInfo {
|
|||
struct CallInfo *previous, *next; /* dynamic call link */
|
||||
union {
|
||||
struct { /* only for Lua functions */
|
||||
StkId base; /* base for this function */
|
||||
const Instruction *savedpc;
|
||||
} l;
|
||||
struct { /* only for C functions */
|
||||
|
|
23
lvm.c
23
lvm.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lvm.c,v 2.280 2017/05/11 18:57:46 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.281 2017/05/13 12:57:20 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -659,7 +659,7 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
|
|||
*/
|
||||
void luaV_finishOp (lua_State *L) {
|
||||
CallInfo *ci = L->ci;
|
||||
StkId base = ci->u.l.base;
|
||||
StkId base = ci->func + 1;
|
||||
Instruction inst = *(ci->u.l.savedpc - 1); /* interrupted instruction */
|
||||
OpCode op = GET_OPCODE(inst);
|
||||
switch (op) { /* finish its execution */
|
||||
|
@ -696,7 +696,7 @@ void luaV_finishOp (lua_State *L) {
|
|||
luaV_concat(L, total); /* concat them (may yield again) */
|
||||
}
|
||||
/* move final result to final position */
|
||||
setobj2s(L, ci->u.l.base + GETARG_A(inst), L->top - 1);
|
||||
setobj2s(L, ci->func + 1 + GETARG_A(inst), L->top - 1);
|
||||
L->top = ci->top; /* restore top */
|
||||
break;
|
||||
}
|
||||
|
@ -753,7 +753,7 @@ void luaV_finishOp (lua_State *L) {
|
|||
*/
|
||||
#define dojump(ci,i,e) \
|
||||
{ int a = GETARG_A(i); \
|
||||
if (a != 0) luaF_close(L, ci->u.l.base + a - 1); \
|
||||
if (a != 0) luaF_close(L, ci->func + a); \
|
||||
pc += GETARG_sBx(i) + e; updatemask(L); }
|
||||
|
||||
|
||||
|
@ -772,7 +772,7 @@ void luaV_finishOp (lua_State *L) {
|
|||
** stack, and change the hooks.
|
||||
*/
|
||||
#define Protect(code) \
|
||||
{ savepc(L); {code;}; base = ci->u.l.base; updatemask(L); }
|
||||
{ savepc(L); {code;}; base = ci->func + 1; updatemask(L); }
|
||||
|
||||
|
||||
#define checkGC(L,c) \
|
||||
|
@ -797,7 +797,7 @@ void luaV_execute (lua_State *L) {
|
|||
CallInfo *ci = L->ci;
|
||||
LClosure *cl;
|
||||
TValue *k;
|
||||
StkId base; /* local copy of 'ci->u.l.base' */
|
||||
StkId base; /* local copy of 'ci->func + 1' */
|
||||
int mask; /* local copy of 'L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)' */
|
||||
const Instruction *pc; /* local copy of 'ci->u.l.savedpc' */
|
||||
ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */
|
||||
|
@ -806,14 +806,14 @@ void luaV_execute (lua_State *L) {
|
|||
cl = clLvalue(ci->func); /* local reference to function's closure */
|
||||
k = cl->p->k; /* local reference to function's constant table */
|
||||
updatemask(L);
|
||||
base = ci->u.l.base;
|
||||
base = ci->func + 1;
|
||||
pc = ci->u.l.savedpc;
|
||||
/* main loop of interpreter */
|
||||
for (;;) {
|
||||
Instruction i;
|
||||
StkId ra;
|
||||
vmfetch();
|
||||
lua_assert(base == ci->u.l.base);
|
||||
lua_assert(base == ci->func + 1);
|
||||
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
|
||||
vmdispatch (GET_OPCODE(i)) {
|
||||
vmcase(OP_MOVE) {
|
||||
|
@ -1288,19 +1288,18 @@ void luaV_execute (lua_State *L) {
|
|||
StkId nfunc = nci->func; /* called function */
|
||||
StkId ofunc = oci->func; /* caller function */
|
||||
/* last stack slot filled by 'precall' */
|
||||
StkId lim = nci->u.l.base + getproto(nfunc)->numparams;
|
||||
StkId lim = nci->func + 1 + getproto(nfunc)->numparams;
|
||||
int aux;
|
||||
/* close all upvalues from previous call */
|
||||
if (cl->p->sizep > 0) luaF_close(L, oci->u.l.base);
|
||||
if (cl->p->sizep > 0) luaF_close(L, oci->func + 1);
|
||||
/* move new frame into old one */
|
||||
for (aux = 0; nfunc + aux < lim; aux++)
|
||||
setobjs2s(L, ofunc + aux, nfunc + aux);
|
||||
oci->u.l.base = ofunc + (nci->u.l.base - nfunc); /* correct base */
|
||||
oci->top = L->top = ofunc + (L->top - nfunc); /* correct top */
|
||||
oci->u.l.savedpc = nci->u.l.savedpc;
|
||||
oci->callstatus |= CIST_TAIL; /* function was tail called */
|
||||
ci = L->ci = oci; /* remove new frame */
|
||||
lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize);
|
||||
lua_assert(L->top == oci->func + 1 + getproto(ofunc)->maxstacksize);
|
||||
goto newframe; /* restart luaV_execute over new Lua function */
|
||||
}
|
||||
vmbreak;
|
||||
|
|
Loading…
Reference in New Issue