diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 12:11:54 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-07-06 12:11:54 -0300 |
| commit | 6298903e35217ab69c279056f925fb72900ce0b7 (patch) | |
| tree | 106a8728643e81daff718015fd63d40f6fdf1c2f | |
| parent | b57574d6fb9071b2f8f261b32c9378ed72db7023 (diff) | |
| download | lua-6298903e35217ab69c279056f925fb72900ce0b7.tar.gz lua-6298903e35217ab69c279056f925fb72900ce0b7.tar.bz2 lua-6298903e35217ab69c279056f925fb72900ce0b7.zip | |
Keep minimum size when shrinking a stack
When shrinking a stack (during GC), do not make it smaller than the
initial stack size.
| -rw-r--r-- | ldo.c | 5 |
1 files changed, 2 insertions, 3 deletions
| @@ -245,13 +245,12 @@ static int stackinuse (lua_State *L) { | |||
| 245 | 245 | ||
| 246 | void luaD_shrinkstack (lua_State *L) { | 246 | void luaD_shrinkstack (lua_State *L) { |
| 247 | int inuse = stackinuse(L); | 247 | int inuse = stackinuse(L); |
| 248 | int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK; | 248 | int goodsize = inuse + BASIC_STACK_SIZE; |
| 249 | if (goodsize > LUAI_MAXSTACK) | 249 | if (goodsize > LUAI_MAXSTACK) |
| 250 | goodsize = LUAI_MAXSTACK; /* respect stack limit */ | 250 | goodsize = LUAI_MAXSTACK; /* respect stack limit */ |
| 251 | /* if thread is currently not handling a stack overflow and its | 251 | /* if thread is currently not handling a stack overflow and its |
| 252 | good size is smaller than current size, shrink its stack */ | 252 | good size is smaller than current size, shrink its stack */ |
| 253 | if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && | 253 | if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L->stacksize) |
| 254 | goodsize < L->stacksize) | ||
| 255 | luaD_reallocstack(L, goodsize, 0); /* ok if that fails */ | 254 | luaD_reallocstack(L, goodsize, 0); /* ok if that fails */ |
| 256 | else /* don't change stack */ | 255 | else /* don't change stack */ |
| 257 | condmovestack(L,{},{}); /* (change only for debugging) */ | 256 | condmovestack(L,{},{}); /* (change only for debugging) */ |
