'luaV_execute' gets call info as extra argument (it is always

available on call sites)
This commit is contained in:
Roberto Ierusalimschy
2017-11-29 11:02:17 -02:00
parent 36aecd4548
commit c766e4103d
3 changed files with 11 additions and 11 deletions

13
ldo.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldo.c,v 2.174 2017/11/23 16:35:54 roberto Exp roberto $ ** $Id: ldo.c,v 2.175 2017/11/23 18:29:41 roberto Exp roberto $
** Stack and Call structure of Lua ** Stack and Call structure of Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -468,7 +468,7 @@ void luaD_call (lua_State *L, StkId func, int nresults) {
ci->callstatus = CIST_LUA; ci->callstatus = CIST_LUA;
if (L->hookmask) if (L->hookmask)
callhook(L, ci, 0); callhook(L, ci, 0);
luaV_execute(L); /* run the function */ luaV_execute(L, ci); /* run the function */
break; break;
} }
default: { /* not a function */ default: { /* not a function */
@@ -525,14 +525,15 @@ static void finishCcall (lua_State *L, int status) {
** status is LUA_YIELD). ** status is LUA_YIELD).
*/ */
static void unroll (lua_State *L, void *ud) { static void unroll (lua_State *L, void *ud) {
CallInfo *ci;
if (ud != NULL) /* error status? */ if (ud != NULL) /* error status? */
finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */ finishCcall(L, *(int *)ud); /* finish 'lua_pcallk' callee */
while (L->ci != &L->base_ci) { /* something in the stack */ while ((ci = L->ci) != &L->base_ci) { /* something in the stack */
if (!isLua(L->ci)) /* C function? */ if (!isLua(ci)) /* C function? */
finishCcall(L, LUA_YIELD); /* complete its execution */ finishCcall(L, LUA_YIELD); /* complete its execution */
else { /* Lua function */ else { /* Lua function */
luaV_finishOp(L); /* finish interrupted instruction */ luaV_finishOp(L); /* finish interrupted instruction */
luaV_execute(L); /* execute down to higher C 'boundary' */ luaV_execute(L, ci); /* execute down to higher C 'boundary' */
} }
} }
} }
@@ -606,7 +607,7 @@ static void resume (lua_State *L, void *ud) {
lua_assert(L->status == LUA_YIELD); lua_assert(L->status == LUA_YIELD);
L->status = LUA_OK; /* mark that it is running (again) */ L->status = LUA_OK; /* mark that it is running (again) */
if (isLua(ci)) /* yielded inside a hook? */ if (isLua(ci)) /* yielded inside a hook? */
luaV_execute(L); /* just continue running Lua code */ luaV_execute(L, ci); /* just continue running Lua code */
else { /* 'common' yield */ else { /* 'common' yield */
if (ci->u.c.k != NULL) { /* does it have a continuation function? */ if (ci->u.c.k != NULL) { /* does it have a continuation function? */
lua_unlock(L); lua_unlock(L);

5
lvm.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.319 2017/11/28 12:58:18 roberto Exp roberto $ ** $Id: lvm.c,v 2.320 2017/11/28 14:51:00 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -823,8 +823,7 @@ void luaV_finishOp (lua_State *L) {
#define vmbreak break #define vmbreak break
void luaV_execute (lua_State *L) { void luaV_execute (lua_State *L, CallInfo *ci) {
CallInfo *ci = L->ci;
LClosure *cl = clLvalue(s2v(ci->func)); LClosure *cl = clLvalue(s2v(ci->func));
TValue *k = cl->p->k; TValue *k = cl->p->k;
StkId base = ci->func + 1; StkId base = ci->func + 1;

4
lvm.h
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lvm.h,v 2.46 2017/07/07 16:34:32 roberto Exp roberto $ ** $Id: lvm.h,v 2.47 2017/11/08 14:50:23 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -112,7 +112,7 @@ LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key, LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
TValue *val, const TValue *slot); TValue *val, const TValue *slot);
LUAI_FUNC void luaV_finishOp (lua_State *L); LUAI_FUNC void luaV_finishOp (lua_State *L);
LUAI_FUNC void luaV_execute (lua_State *L); LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci);
LUAI_FUNC void luaV_concat (lua_State *L, int total); LUAI_FUNC void luaV_concat (lua_State *L, int total);
LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y);
LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y);