diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-03-04 10:32:29 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-03-04 10:32:29 -0300 |
| commit | 1817dfc3016efc09cfa2c7aee06b22fe1d130652 (patch) | |
| tree | 3de048bf2b14c6547f9ba15134b6b7fd0455f844 | |
| parent | 7837e34e567e174e21c7971439e6a4a093addb06 (diff) | |
| download | lua-1817dfc3016efc09cfa2c7aee06b22fe1d130652.tar.gz lua-1817dfc3016efc09cfa2c7aee06b22fe1d130652.tar.bz2 lua-1817dfc3016efc09cfa2c7aee06b22fe1d130652.zip | |
initial separation, in CallInfo, of what is relevant only to Lua
functions or only to C functions
| -rw-r--r-- | ldebug.c | 6 | ||||
| -rw-r--r-- | ldo.c | 8 | ||||
| -rw-r--r-- | lstate.h | 8 | ||||
| -rw-r--r-- | lvm.c | 4 |
4 files changed, 15 insertions, 11 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.41 2008/08/26 13:27:42 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.42 2008/10/30 15:39:30 roberto Exp roberto $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -89,7 +89,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
| 89 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { | 89 | for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) { |
| 90 | level--; | 90 | level--; |
| 91 | if (isLua(ci)) /* Lua function? */ | 91 | if (isLua(ci)) /* Lua function? */ |
| 92 | level -= ci->tailcalls; /* skip lost tail calls */ | 92 | level -= ci->u.l.tailcalls; /* skip lost tail calls */ |
| 93 | } | 93 | } |
| 94 | if (level == 0 && ci > L->base_ci) { /* level found? */ | 94 | if (level == 0 && ci > L->base_ci) { /* level found? */ |
| 95 | status = 1; | 95 | status = 1; |
| @@ -527,7 +527,7 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, | |||
| 527 | static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { | 527 | static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { |
| 528 | TMS tm = 0; | 528 | TMS tm = 0; |
| 529 | Instruction i; | 529 | Instruction i; |
| 530 | if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) | 530 | if ((isLua(ci) && ci->u.l.tailcalls > 0) || !isLua(ci - 1)) |
| 531 | return NULL; /* calling function is not Lua (or is unknown) */ | 531 | return NULL; /* calling function is not Lua (or is unknown) */ |
| 532 | ci--; /* calling function */ | 532 | ci--; /* calling function */ |
| 533 | i = ci_func(ci)->l.p->code[currentpc(L, ci)]; | 533 | i = ci_func(ci)->l.p->code[currentpc(L, ci)]; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.52 2009/02/18 14:52:03 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.53 2009/03/03 18:51:24 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -289,7 +289,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 289 | ci->top = L->base + p->maxstacksize; | 289 | ci->top = L->base + p->maxstacksize; |
| 290 | lua_assert(ci->top <= L->stack_last); | 290 | lua_assert(ci->top <= L->stack_last); |
| 291 | L->savedpc = p->code; /* starting point */ | 291 | L->savedpc = p->code; /* starting point */ |
| 292 | ci->tailcalls = 0; | 292 | ci->u.l.tailcalls = 0; |
| 293 | ci->callstatus = CIST_LUA; | 293 | ci->callstatus = CIST_LUA; |
| 294 | ci->nresults = nresults; | 294 | ci->nresults = nresults; |
| 295 | for (st = L->top; st < ci->top; st++) | 295 | for (st = L->top; st < ci->top; st++) |
| @@ -328,8 +328,8 @@ static StkId callrethooks (lua_State *L, StkId firstResult) { | |||
| 328 | ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ | 328 | ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ |
| 329 | luaD_callhook(L, LUA_HOOKRET, -1); | 329 | luaD_callhook(L, LUA_HOOKRET, -1); |
| 330 | if (isLua(L->ci)) { /* Lua function? */ | 330 | if (isLua(L->ci)) { /* Lua function? */ |
| 331 | while ((L->hookmask & LUA_MASKRET) && L->ci->tailcalls--) /* tail calls */ | 331 | while ((L->hookmask & LUA_MASKRET) && L->ci->u.l.tailcalls--) |
| 332 | luaD_callhook(L, LUA_HOOKTAILRET, -1); | 332 | luaD_callhook(L, LUA_HOOKTAILRET, -1); /* ret. hooks for tail calls */ |
| 333 | } | 333 | } |
| 334 | return restorestack(L, fr); | 334 | return restorestack(L, fr); |
| 335 | } | 335 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.h,v 2.36 2008/08/26 13:27:42 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.37 2009/02/18 17:20:56 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -83,7 +83,11 @@ typedef struct CallInfo { | |||
| 83 | const Instruction *savedpc; | 83 | const Instruction *savedpc; |
| 84 | short nresults; /* expected number of results from this function */ | 84 | short nresults; /* expected number of results from this function */ |
| 85 | lu_byte callstatus; | 85 | lu_byte callstatus; |
| 86 | int tailcalls; /* number of tail calls lost under this entry */ | 86 | union { |
| 87 | struct { /* only for Lua functions */ | ||
| 88 | int tailcalls; /* number of tail calls lost under this entry */ | ||
| 89 | } l; | ||
| 90 | } u; | ||
| 87 | } CallInfo; | 91 | } CallInfo; |
| 88 | 92 | ||
| 89 | 93 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.81 2009/02/16 20:09:28 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.82 2009/03/02 16:34:23 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -622,7 +622,7 @@ void luaV_execute (lua_State *L) { | |||
| 622 | ci->top = L->top = func+aux; /* correct top */ | 622 | ci->top = L->top = func+aux; /* correct top */ |
| 623 | lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); | 623 | lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize); |
| 624 | ci->savedpc = L->savedpc; | 624 | ci->savedpc = L->savedpc; |
| 625 | ci->tailcalls++; /* one more call lost */ | 625 | ci->u.l.tailcalls++; /* one more call lost */ |
| 626 | L->ci--; /* remove new frame */ | 626 | L->ci--; /* remove new frame */ |
| 627 | goto reentry; | 627 | goto reentry; |
| 628 | } | 628 | } |
