diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-21 15:19:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-11-21 15:19:11 -0200 |
commit | 5142e630bf91e2353f4397e03593ab56b3a07b86 (patch) | |
tree | 1402e556c77f5c45e956ea6cd3192cffaf2e28d1 | |
parent | 010bbd9d9c8c6e7d38062df79e886466de5a835a (diff) | |
download | lua-5142e630bf91e2353f4397e03593ab56b3a07b86.tar.gz lua-5142e630bf91e2353f4397e03593ab56b3a07b86.tar.bz2 lua-5142e630bf91e2353f4397e03593ab56b3a07b86.zip |
new macro `condhardstacktests' to control hard stack tests
-rw-r--r-- | ldo.c | 3 | ||||
-rw-r--r-- | ldo.h | 15 | ||||
-rw-r--r-- | lgc.c | 4 |
3 files changed, 18 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.205 2002/11/21 15:16:04 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.206 2002/11/21 15:46:44 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 | */ |
@@ -218,6 +218,7 @@ StkId luaD_precall (lua_State *L, StkId func) { | |||
218 | if (!ttisfunction(func)) /* `func' is not a function? */ | 218 | if (!ttisfunction(func)) /* `func' is not a function? */ |
219 | func = tryfuncTM(L, func); /* check the `function' tag method */ | 219 | func = tryfuncTM(L, func); /* check the `function' tag method */ |
220 | if (L->ci + 1 == L->end_ci) luaD_growCI(L); | 220 | if (L->ci + 1 == L->end_ci) luaD_growCI(L); |
221 | else condhardstacktests(luaD_reallocCI(L, L->size_ci)); | ||
221 | cl = &clvalue(func)->l; | 222 | cl = &clvalue(func)->l; |
222 | if (!cl->isC) { /* Lua function? prepare its call */ | 223 | if (!cl->isC) { /* Lua function? prepare its call */ |
223 | CallInfo *ci; | 224 | CallInfo *ci; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.h,v 1.52 2002/09/02 20:00:41 roberto Exp roberto $ | 2 | ** $Id: ldo.h,v 1.53 2002/11/21 16:46:16 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,10 +13,21 @@ | |||
13 | #include "lzio.h" | 13 | #include "lzio.h" |
14 | 14 | ||
15 | 15 | ||
16 | /* | ||
17 | ** macro to control inclusion of some hard tests on stack reallocation | ||
18 | */ | ||
19 | #ifndef CONDHARDSTACKTESTS | ||
20 | #define condhardstacktests(x) { /* empty */ } | ||
21 | #else | ||
22 | #define condhardstacktests(x) x | ||
23 | #endif | ||
24 | |||
16 | 25 | ||
17 | #define luaD_checkstack(L,n) \ | 26 | #define luaD_checkstack(L,n) \ |
18 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TObject)) \ | 27 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TObject)) \ |
19 | luaD_growstack(L, n) | 28 | luaD_growstack(L, n); \ |
29 | else condhardstacktests(luaD_reallocstack(L, L->stacksize)); | ||
30 | |||
20 | 31 | ||
21 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} | 32 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} |
22 | 33 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 1.160 2002/11/21 14:17:15 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 1.161 2002/11/21 15:46:20 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -224,9 +224,11 @@ static void checkstacksizes (lua_State *L, StkId max) { | |||
224 | int used = L->ci - L->base_ci; /* number of `ci' in use */ | 224 | int used = L->ci - L->base_ci; /* number of `ci' in use */ |
225 | if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) | 225 | if (4*used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) |
226 | luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ | 226 | luaD_reallocCI(L, L->size_ci/2); /* still big enough... */ |
227 | else condhardstacktests(luaD_reallocCI(L, L->size_ci)); | ||
227 | used = max - L->stack; /* part of stack in use */ | 228 | used = max - L->stack; /* part of stack in use */ |
228 | if (4*used < L->stacksize && 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) | 229 | if (4*used < L->stacksize && 2*(BASIC_STACK_SIZE+EXTRA_STACK) < L->stacksize) |
229 | luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ | 230 | luaD_reallocstack(L, L->stacksize/2); /* still big enough... */ |
231 | else condhardstacktests(luaD_reallocstack(L, L->stacksize)); | ||
230 | } | 232 | } |
231 | 233 | ||
232 | 234 | ||