diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-22 12:40:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-22 12:40:47 -0200 |
commit | 8004ab756fe2c9fa5da79da6d17f8e11ab7dea26 (patch) | |
tree | 269c7057188f70aa9fe9c7f76b7062d79fa92dea | |
parent | ee5ef0f295a317457132912c817d0ad9ee74e8af (diff) | |
download | lua-8004ab756fe2c9fa5da79da6d17f8e11ab7dea26.tar.gz lua-8004ab756fe2c9fa5da79da6d17f8e11ab7dea26.tar.bz2 lua-8004ab756fe2c9fa5da79da6d17f8e11ab7dea26.zip |
hook test in 'luaV_execute' reduced to minimum (rest done in
'luaG_traceexec'; no difference in performance for the non-hook
case, but keeps 'luaV_execute' a little simpler) + 'base' updates
replaced by 'Protect' (which serves this rule)
-rw-r--r-- | lvm.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.254 2015/10/20 17:41:35 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.255 2015/10/20 17:56:21 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 | */ |
@@ -773,10 +773,8 @@ void luaV_execute (lua_State *L) { | |||
773 | for (;;) { | 773 | for (;;) { |
774 | Instruction i = *(ci->u.l.savedpc++); | 774 | Instruction i = *(ci->u.l.savedpc++); |
775 | StkId ra; | 775 | StkId ra; |
776 | if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && | 776 | if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) |
777 | (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { | ||
778 | Protect(luaG_traceexec(L)); | 777 | Protect(luaG_traceexec(L)); |
779 | } | ||
780 | /* WARNING: several calls may realloc the stack and invalidate 'ra' */ | 778 | /* WARNING: several calls may realloc the stack and invalidate 'ra' */ |
781 | ra = RA(i); | 779 | ra = RA(i); |
782 | lua_assert(base == ci->u.l.base); | 780 | lua_assert(base == ci->u.l.base); |
@@ -1109,8 +1107,9 @@ void luaV_execute (lua_State *L) { | |||
1109 | int nresults = GETARG_C(i) - 1; | 1107 | int nresults = GETARG_C(i) - 1; |
1110 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ | 1108 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ |
1111 | if (luaD_precall(L, ra, nresults)) { /* C function? */ | 1109 | if (luaD_precall(L, ra, nresults)) { /* C function? */ |
1112 | if (nresults >= 0) L->top = ci->top; /* adjust results */ | 1110 | if (nresults >= 0) |
1113 | base = ci->u.l.base; | 1111 | L->top = ci->top; /* adjust results */ |
1112 | Protect(); /* update 'base' */ | ||
1114 | } | 1113 | } |
1115 | else { /* Lua function */ | 1114 | else { /* Lua function */ |
1116 | ci = L->ci; | 1115 | ci = L->ci; |
@@ -1123,8 +1122,9 @@ void luaV_execute (lua_State *L) { | |||
1123 | int b = GETARG_B(i); | 1122 | int b = GETARG_B(i); |
1124 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ | 1123 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ |
1125 | lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); | 1124 | lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); |
1126 | if (luaD_precall(L, ra, LUA_MULTRET)) /* C function? */ | 1125 | if (luaD_precall(L, ra, LUA_MULTRET)) { /* C function? */ |
1127 | base = ci->u.l.base; | 1126 | Protect(); /* update 'base' */ |
1127 | } | ||
1128 | else { | 1128 | else { |
1129 | /* tail call: put called frame (n) in place of caller one (o) */ | 1129 | /* tail call: put called frame (n) in place of caller one (o) */ |
1130 | CallInfo *nci = L->ci; /* called frame */ | 1130 | CallInfo *nci = L->ci; /* called frame */ |