diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-21 16:40:47 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-21 16:40:47 -0200 |
commit | 5bdee4f81057698cf7da2bb5da814984170abf8c (patch) | |
tree | 254f8575ed2b1bc4973887caab35404cc7d0cd44 /ldo.h | |
parent | 48098c42ff69154811f234c1446b4fcbf2f15e94 (diff) | |
download | lua-5bdee4f81057698cf7da2bb5da814984170abf8c.tar.gz lua-5bdee4f81057698cf7da2bb5da814984170abf8c.tar.bz2 lua-5bdee4f81057698cf7da2bb5da814984170abf8c.zip |
small changes to allow 'precall' to spend time preserving 'func'
only when needed (that is, when stack actually changes)
Diffstat (limited to 'ldo.h')
-rw-r--r-- | ldo.h | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp roberto $ | 2 | ** $Id: ldo.h,v 2.22 2015/05/22 17:48:19 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 | */ |
@@ -13,8 +13,19 @@ | |||
13 | #include "lzio.h" | 13 | #include "lzio.h" |
14 | 14 | ||
15 | 15 | ||
16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ | 16 | /* |
17 | luaD_growstack(L, n); else condmovestack(L); | 17 | ** Macro to check stack size and grow stack if needed. Parameters |
18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the | ||
19 | ** stack across realalocations, doing the work only when needed. | ||
20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation | ||
21 | ** at every check. | ||
22 | */ | ||
23 | #define luaD_checkstackaux(L,n,pre,pos) \ | ||
24 | if (L->stack_last - L->top <= (n)) \ | ||
25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } | ||
26 | |||
27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ | ||
28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,,) | ||
18 | 29 | ||
19 | 30 | ||
20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} | 31 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} |