MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaD_shrinkstack

Function luaD_shrinkstack

third-party/lua-5.5.0/src/ldo.c:411–423  ·  view source on GitHub ↗

** If stack size is more than 3 times the current use, reduce that size ** to twice the current use. (So, the final stack size is at most 2/3 the ** previous size, and half of its entries are empty.) ** As a particular case, if stack was handling a stack overflow and now ** it is not, 'max' (limited by MAXSTACK) will be smaller than ** stacksize (equal to ERRORSTACKSIZE in this case), and so the s

Source from the content-addressed store, hash-verified

409** will be reduced to a "regular" size.
410*/
411void luaD_shrinkstack (lua_State *L) {
412 int inuse = stackinuse(L);
413 int max = (inuse > MAXSTACK / 3) ? MAXSTACK : inuse * 3;
414 /* if thread is currently not handling a stack overflow and its
415 size is larger than maximum "reasonable" size, shrink it */
416 if (inuse <= MAXSTACK && stacksize(L) > max) {
417 int nsize = (inuse > MAXSTACK / 2) ? MAXSTACK : inuse * 2;
418 luaD_reallocstack(L, nsize, 0); /* ok if that fails */
419 }
420 else /* don't change stack */
421 condmovestack(L,(void)0,(void)0); /* (change only for debugging) */
422 luaE_shrinkCI(L); /* shrink CI list */
423}
424
425
426void luaD_inctop (lua_State *L) {

Callers 3

finishpcallkFunction · 0.70
luaD_pcallFunction · 0.70
traversethreadFunction · 0.70

Calls 3

stackinuseFunction · 0.70
luaD_reallocstackFunction · 0.70
luaE_shrinkCIFunction · 0.70

Tested by

no test coverage detected