lua_checkstack necessity

  • From: Tyson Nottingham <tgnottingham@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 23 Oct 2014 11:23:09 -0700

I've noticed that many LuaJIT C API functions manage the stack size
without requiring me to use lua_checkstack(). E.g. I can call
lua_pushnumber() up to around LUAI_MAXSTACK times in a loop without
any apparent memory issues. In the source, I can see that many
functions call incr_top(), which grows the stack according to my
understanding.

Does this make calling lua_checkstack() unnecessary before calling the
basic functions that push elements onto the stack (lua_pushxxx(),
lua_next(), etc.) when using the LuaJIT implementation? Are there any
exceptions? Is this implicit stack management something that I can
rely on, or should I consider it an implementation detail that may
change? Also, is this documented anywhere?

Thanks,
Tyson

Other related posts: