lua-users home
lua-l archive

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


> My script (https://hastebin.com/adaqajufeb.makefile) is declaring an
> object with a rather complex structure ; it is rejected with the
> following error message with latest
> lua :
> [string "settings = {..."]:639: function or expression needs too many
> registers '0.51041179895401'.
> [...]
> I suspect that I hit a cornercase of some sort : since several
> constructors are nested they allocate some register space but don't
> release it on time so that constructors in the deepest level in the
> structure are able to do their own allocation ; however I'm not 100%
> sure I properly diagnosed the issue. I don't know if it's possible to
> fix, tweaking the defines in lua.h or luaconf.h (LUAI_MAXSTACK...)
> didn't help.
> 
> I discovered that modifying LFIELDS_PER_FLUSH in lopcodes.h helps :
> changing it from 50 to 10 makes my code work, however customisation of
> this define seems unsupported (it's neither in lua.h nor in luaconf.h)
> and I fear that it may bring regression in other part of the code.
> 
> Is there a proper fix available for this issue that doesn't require
> changing the LUA code ?

Any compiler has several limits. In this case, as you realized, the
limit is connected with too many nestings of non-small constructors.
(Your code probably has five or more levels of nesting, each one
with dozens of elements.)

You can change LFIELDS_PER_FLUSH without problems, but sooner or later
you can hit the limit again. A better solution could be to reorganize
your table.

-- Roberto