lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I get the "constant table overflow" message while compiling a small test
file.  I am doing this with a 16-bit integer version of Lua.  It does
not happen if I use a 32-bit version.

In the 16-bit version I have used

  #define SIZE_INSTRUCTION        16
  #define SIZE_B                   5

The consequence of this seems to be that 

  #define SIZE_A          (SIZE_INSTRUCTION-(SIZE_OP+SIZE_B))

sets SIZE_A to 16-(6+5) = 5.  Hence, since SIZE_A < BITS_INT-1, we get

  #define MAXARG_A        ((1<<SIZE_A)-1)

whence MAXARG_A becomes ((1<<5)-1) = 31.  The place where the effect of
this constant is felt is in the following function:

  static void pushclosure (LexState *ls, FuncState *func) {
    FuncState *fs = ls->fs;
    Proto *f = fs->f;
    ...
    luaM_growvector(ls->L, f->kproto, f->nkproto, 1, Proto *,
                  "constant table overflow", MAXARG_A);

f->nkproto counts from 0 to 29 for every function encountered before it
gives up.  MAXARG_A appears to be a limit for "functions defined inside
the function".  Since I have no functions defined inside functions, I
suppose what is meant is functions inside the chunk.

So, the bottom line seems to be that, in a 16-bit version, there can
only be 29-30 functions in a chunk or inside another function.  Am I
right?

I can live with this limitation.  I just want to ask if there is any way
around it and whether there are other limitations that might make
problems for the runtime system, even if I make small chunks.

I attach the program that produces the error message, pared down to its
essentials.  The message disappears if any one of these functions is
commented out. 

-------------------------------- lua file -----------------------------

function delegate (t, i)
end

settagmethod(tag{}, "index", delegate)

Str = {}

function Str:disp () end 
function Str:pack () end 
function Str:unpack (s) end 
function Str:clear () end 
function Str:size () end 
function Str:new (dim) end 

Num = {}

function Num:disp () end 
function Num:pack () end 
function Num:unpack (s) end 
function Num:clear () end 
function Num:size () end 
function Num:new (dim) end 

Bool = {}

function Bool:disp () end 
function Bool:pack () end 
function Bool:unpack (s) end 
function Bool:clear () end 
function Bool:size () end 
function Bool:new () end 

Date = {}

function Date:disp () end 
function Date:pack () end
function Date:unpack (s) end 
function Date:clear () end 
function Date:size () end 
function Date:new () end 

function extra_func_1 () end
function extra_func_2 () end
function extra_func_3 () end
function extra_func_4 () end
function extra_func_5 () end
function extra_func_6 () end

-- 
    Tore