mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
Keep minimum size when shrinking a stack
When shrinking a stack (during GC), do not make it smaller than the initial stack size.
This commit is contained in:
parent
b57574d6fb
commit
6298903e35
1 changed files with 2 additions and 3 deletions
5
ldo.c
5
ldo.c
|
|
@ -245,13 +245,12 @@ static int stackinuse (lua_State *L) {
|
|||
|
||||
void luaD_shrinkstack (lua_State *L) {
|
||||
int inuse = stackinuse(L);
|
||||
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
|
||||
int goodsize = inuse + BASIC_STACK_SIZE;
|
||||
if (goodsize > LUAI_MAXSTACK)
|
||||
goodsize = LUAI_MAXSTACK; /* respect stack limit */
|
||||
/* if thread is currently not handling a stack overflow and its
|
||||
good size is smaller than current size, shrink its stack */
|
||||
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
|
||||
goodsize < L->stacksize)
|
||||
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) && goodsize < L->stacksize)
|
||||
luaD_reallocstack(L, goodsize, 0); /* ok if that fails */
|
||||
else /* don't change stack */
|
||||
condmovestack(L,{},{}); /* (change only for debugging) */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue