aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-03-09 11:10:04 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2023-03-09 11:10:04 -0300
commit1de2f31694ddbc86b18e491c8aedc91791f512e2 (patch)
tree01fa1b5fe0cce50c062f8ed07f98741b339bbb66 /ldo.c
parent02bab9fc258fe1cbc6088b1bd61193499d058eff (diff)
downloadlua-1de2f31694ddbc86b18e491c8aedc91791f512e2.tar.gz
lua-1de2f31694ddbc86b18e491c8aedc91791f512e2.tar.bz2
lua-1de2f31694ddbc86b18e491c8aedc91791f512e2.zip
Corrected support for 16-bit systems
We still need access to a 16-bit system to correctly test these changes.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/ldo.c b/ldo.c
index c30cde76..2a0017ca 100644
--- a/ldo.c
+++ b/ldo.c
@@ -299,17 +299,13 @@ static int stackinuse (lua_State *L) {
299*/ 299*/
300void luaD_shrinkstack (lua_State *L) { 300void 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*/
632l_sinline void ccall (lua_State *L, StkId func, int nResults, int inc) { 628l_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)) {