diff options
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -299,17 +299,13 @@ static int stackinuse (lua_State *L) { | |||
299 | */ | 299 | */ |
300 | void luaD_shrinkstack (lua_State *L) { | 300 | void luaD_shrinkstack (lua_State *L) { |
301 | int inuse = stackinuse(L); | 301 | int inuse = stackinuse(L); |
302 | int nsize = inuse * 2; /* proposed new size */ | 302 | int max = (inuse > LUAI_MAXSTACK / 3) ? LUAI_MAXSTACK : inuse * 3; |
303 | int max = inuse * 3; /* maximum "reasonable" size */ | ||
304 | if (max > LUAI_MAXSTACK) { | ||
305 | max = LUAI_MAXSTACK; /* respect stack limit */ | ||
306 | if (nsize > LUAI_MAXSTACK) | ||
307 | nsize = LUAI_MAXSTACK; | ||
308 | } | ||
309 | /* if thread is currently not handling a stack overflow and its | 303 | /* if thread is currently not handling a stack overflow and its |
310 | size is larger than maximum "reasonable" size, shrink it */ | 304 | size is larger than maximum "reasonable" size, shrink it */ |
311 | if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) | 305 | if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) { |
306 | int nsize = (inuse > LUAI_MAXSTACK / 2) ? LUAI_MAXSTACK : inuse * 2; | ||
312 | luaD_reallocstack(L, nsize, 0); /* ok if that fails */ | 307 | luaD_reallocstack(L, nsize, 0); /* ok if that fails */ |
308 | } | ||
313 | else /* don't change stack */ | 309 | else /* don't change stack */ |
314 | condmovestack(L,{},{}); /* (change only for debugging) */ | 310 | condmovestack(L,{},{}); /* (change only for debugging) */ |
315 | luaE_shrinkCI(L); /* shrink CI list */ | 311 | luaE_shrinkCI(L); /* shrink CI list */ |
@@ -629,7 +625,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
629 | ** check the stack before doing anything else. 'luaD_precall' already | 625 | ** check the stack before doing anything else. 'luaD_precall' already |
630 | ** does that. | 626 | ** does that. |
631 | */ | 627 | */ |
632 | l_sinline void ccall (lua_State *L, StkId func, int nResults, int inc) { | 628 | l_sinline void ccall (lua_State *L, StkId func, int nResults, l_uint32 inc) { |
633 | CallInfo *ci; | 629 | CallInfo *ci; |
634 | L->nCcalls += inc; | 630 | L->nCcalls += inc; |
635 | if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) { | 631 | if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) { |