diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-07 13:18:04 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-07 13:18:04 -0200 |
commit | 318a9a5859826d7af0294664e206236fc8814319 (patch) | |
tree | 31a00af286880036e5ef165fbbdaf7df9a04cfc1 /lvm.c | |
parent | 73d797ce7ea4c547cb97e39633a71a242c7356c8 (diff) | |
download | lua-318a9a5859826d7af0294664e206236fc8814319.tar.gz lua-318a9a5859826d7af0294664e206236fc8814319.tar.bz2 lua-318a9a5859826d7af0294664e206236fc8814319.zip |
new opcode 'PREPVARARG'
(avoids test for vararg function in all function calls)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.336 2018/01/29 16:21:35 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.337 2018/02/06 19:16:56 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 | */ |
@@ -835,12 +835,17 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
835 | int trap; | 835 | int trap; |
836 | tailcall: | 836 | tailcall: |
837 | trap = L->hookmask; | 837 | trap = L->hookmask; |
838 | if (trap) | ||
839 | luaD_hookcall(L, ci); | ||
840 | cl = clLvalue(s2v(ci->func)); | 838 | cl = clLvalue(s2v(ci->func)); |
841 | k = cl->p->k; | 839 | k = cl->p->k; |
842 | base = ci->func + 1; | ||
843 | pc = ci->u.l.savedpc; | 840 | pc = ci->u.l.savedpc; |
841 | if (trap) { | ||
842 | if (cl->p->is_vararg) | ||
843 | trap = 0; /* hooks will start with PREPVARARG instruction */ | ||
844 | else if (pc == cl->p->code) /* first instruction (not resuming)? */ | ||
845 | luaD_hookcall(L, ci); | ||
846 | ci->u.l.trap = 1; /* there may be other hooks */ | ||
847 | } | ||
848 | base = ci->func + 1; | ||
844 | /* main loop of interpreter */ | 849 | /* main loop of interpreter */ |
845 | for (;;) { | 850 | for (;;) { |
846 | int cond; /* flag for conditional jumps */ | 851 | int cond; /* flag for conditional jumps */ |
@@ -1701,6 +1706,16 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1701 | Protect(luaT_getvarargs(L, vtab, ra, n)); | 1706 | Protect(luaT_getvarargs(L, vtab, ra, n)); |
1702 | vmbreak; | 1707 | vmbreak; |
1703 | } | 1708 | } |
1709 | vmcase(OP_PREPVARARG) { | ||
1710 | luaT_adjustvarargs(L, GETARG_A(i), base); | ||
1711 | updatetrap(ci); | ||
1712 | if (trap) { | ||
1713 | luaD_hookcall(L, ci); | ||
1714 | L->oldpc = pc + 1; /* next opcode will be seen as a new line */ | ||
1715 | } | ||
1716 | updatebase(ci); | ||
1717 | vmbreak; | ||
1718 | } | ||
1704 | vmcase(OP_EXTRAARG) { | 1719 | vmcase(OP_EXTRAARG) { |
1705 | lua_assert(0); | 1720 | lua_assert(0); |
1706 | vmbreak; | 1721 | vmbreak; |