Browse Source

Details

Comments + manual + identation + asserts about stack limits that were
not allowing the use of the full stack
pull/27/head
Roberto Ierusalimschy 3 years ago
parent
commit
f3cfd5bf2b
  1. 8
      ldo.c
  2. 9
      loadlib.c
  3. 2
      lvm.c
  4. 4
      manual/manual.of

8
ldo.c

@ -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 */

9
loadlib.c

@ -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);

2
lvm.c

@ -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)) {

4
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}.

Loading…
Cancel
Save