lua-users home
lua-l archive

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


Tom Miles wrote:
> Is there anyway though of modifing lua
> so that it automatically grows the stack if it needs to?

Well, you'd have to ask Roberto about that.

But FYI: in LuaJIT 2.x I'm doing exactly that. I.e. lua_checkstack
is unnecessary (except to catch the 10K hard limit in a few cases).

So far this has turned out to be much simpler for the whole VM.
Adding the stack size checks to a couple of the public API
functions is cheap. And with a little bit of tuning this has no
measurable performance impact at all.

IMHO this whole idea of forcing all Lua/C API users to pre-size
the stack is probably a case of premature optimization. And, as
has just been demonstrated, it causes a lot of grief for
developers.

If you get the pre-sizing wrong, it may silently corrupt memory.
But only under special circumstances that may be hard to
reproduce. Just to be clear, turning on the API checks certainly
helps -- but it does NOT mean you'll find all places where
lua_checkstack is missing or the given limit is too small.

--Mike