aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-04-01 13:55:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2022-04-01 13:55:44 -0300
commitf3cfd5bf2b11ba207c71344243892645157900b7 (patch)
tree87e26a041ebbd9a91fa5862a3e312f3159b6a132 /ldo.c
parent8426d9b4d4df1da3c5b2d759e509ae1c50a86667 (diff)
downloadlua-f3cfd5bf2b11ba207c71344243892645157900b7.tar.gz
lua-f3cfd5bf2b11ba207c71344243892645157900b7.tar.bz2
lua-f3cfd5bf2b11ba207c71344243892645157900b7.zip
Details
Comments + manual + identation + asserts about stack limits that were not allowing the use of the full stack
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ldo.c b/ldo.c
index a48e35f9..8e4faf02 100644
--- a/ldo.c
+++ b/ldo.c
@@ -213,7 +213,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) {
213 213
214 214
215/* 215/*
216** Try to grow the stack by at least 'n' elements. when 'raiseerror' 216** Try to grow the stack by at least 'n' elements. When 'raiseerror'
217** is true, raises any error; otherwise, return 0 in case of errors. 217** is true, raises any error; otherwise, return 0 in case of errors.
218*/ 218*/
219int luaD_growstack (lua_State *L, int n, int raiseerror) { 219int luaD_growstack (lua_State *L, int n, int raiseerror) {
@@ -247,6 +247,10 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) {
247} 247}
248 248
249 249
250/*
251** Compute how much of the stack is being used, by computing the
252** maximum top of all call frames in the stack and the current top.
253*/
250static int stackinuse (lua_State *L) { 254static int stackinuse (lua_State *L) {
251 CallInfo *ci; 255 CallInfo *ci;
252 int res; 256 int res;
@@ -254,7 +258,7 @@ static int stackinuse (lua_State *L) {
254 for (ci = L->ci; ci != NULL; ci = ci->previous) { 258 for (ci = L->ci; ci != NULL; ci = ci->previous) {
255 if (lim < ci->top) lim = ci->top; 259 if (lim < ci->top) lim = ci->top;
256 } 260 }
257 lua_assert(lim <= L->stack_last); 261 lua_assert(lim <= L->stack_last + EXTRA_STACK);
258 res = cast_int(lim - L->stack) + 1; /* part of stack in use */ 262 res = cast_int(lim - L->stack) + 1; /* part of stack in use */
259 if (res < LUA_MINSTACK) 263 if (res < LUA_MINSTACK)
260 res = LUA_MINSTACK; /* ensure a minimum size */ 264 res = LUA_MINSTACK; /* ensure a minimum size */