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 | |
parent | 8426d9b4d4df1da3c5b2d759e509ae1c50a86667 (diff) | |
download | lua-github-f3cfd5bf2b11ba207c71344243892645157900b7.tar.gz |
Details
Comments + manual + identation + asserts about stack limits that were
not allowing the use of the full stack
-rw-r--r-- | ldo.c | 8 | ||||
-rw-r--r-- | loadlib.c | 9 | ||||
-rw-r--r-- | lvm.c | 2 | ||||
-rw-r--r-- | manual/manual.of | 4 |
4 files changed, 17 insertions, 6 deletions
@@ -213,7 +213,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) { /* -** Try to grow the stack by at least 'n' elements. when 'raiseerror' +** Try to grow the stack by at least 'n' elements. When 'raiseerror' ** is true, raises any error; otherwise, return 0 in case of errors. */ int luaD_growstack (lua_State *L, int n, int raiseerror) { @@ -247,6 +247,10 @@ int luaD_growstack (lua_State *L, int n, int raiseerror) { } +/* +** Compute how much of the stack is being used, by computing the +** maximum top of all call frames in the stack and the current top. +*/ static int stackinuse (lua_State *L) { CallInfo *ci; int res; @@ -254,7 +258,7 @@ static int stackinuse (lua_State *L) { for (ci = L->ci; ci != NULL; ci = ci->previous) { if (lim < ci->top) lim = ci->top; } - lua_assert(lim <= L->stack_last); + lua_assert(lim <= L->stack_last + EXTRA_STACK); res = cast_int(lim - L->stack) + 1; /* part of stack in use */ if (res < LUA_MINSTACK) res = LUA_MINSTACK; /* ensure a minimum size */ @@ -708,8 +708,13 @@ static const luaL_Reg ll_funcs[] = { static void createsearcherstable (lua_State *L) { - static const lua_CFunction searchers[] = - {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}; + static const lua_CFunction searchers[] = { + searcher_preload, + searcher_Lua, + searcher_C, + searcher_Croot, + NULL + }; int i; /* create 'searchers' table */ lua_createtable(L, sizeof(searchers)/sizeof(searchers[0]) - 1, 0); @@ -1177,7 +1177,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); #endif lua_assert(base == ci->func + 1); - lua_assert(base <= L->top && L->top < L->stack_last); + lua_assert(base <= L->top && L->top <= L->stack_last); /* invalidate top for instructions not expecting it */ lua_assert(isIT(i) || (cast_void(L->top = base), 1)); vmdispatch (GET_OPCODE(i)) { diff --git a/manual/manual.of b/manual/manual.of index 15f207fa..bd648c6c 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -3981,6 +3981,7 @@ Also @N{returns 0} if any of the indices are not valid. Similar to @Lid{lua_gettable}, but does a raw access (i.e., without metamethods). +The value at @id{index} must be a table. } @@ -4027,6 +4028,7 @@ For other values, this call @N{returns 0}. Similar to @Lid{lua_settable}, but does a raw assignment (i.e., without metamethods). +The value at @id{index} must be a table. } @@ -7280,7 +7282,7 @@ according to the format string @id{fmt} @see{pack}. @LibEntry{string.packsize (fmt)| -Returns the size of a string resulting from @Lid{string.pack} +Returns the length of a string resulting from @Lid{string.pack} with the given format. The format string cannot have the variable-length options @Char{s} or @Char{z} @see{pack}. |