diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-04-01 13:55:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2022-04-01 13:55:44 -0300 |
commit | f3cfd5bf2b11ba207c71344243892645157900b7 (patch) | |
tree | 87e26a041ebbd9a91fa5862a3e312f3159b6a132 /ldo.c | |
parent | 8426d9b4d4df1da3c5b2d759e509ae1c50a86667 (diff) | |
download | lua-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.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 | */ |
219 | int luaD_growstack (lua_State *L, int n, int raiseerror) { | 219 | int 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 | */ | ||
250 | static int stackinuse (lua_State *L) { | 254 | static 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 */ |