Re: Undocumented lua_getstack() ar.i_ci behavior

  • From: Mike Pall <mike-1311@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 20 Nov 2013 02:31:49 +0100

Paul Du Bois wrote:
> While digging through the code trying to figure out how to do an
> O(n) count of stack frames, I ran across behavior where lua_getstack() on
> failure returns the frame count in ar.i_ci.
> 
> Is it likely that this functionality will remain in future revisions of
> luajit?

It'll be there in 2.x for sure. It's used by luaL_traceback to
avoid O(n^2) behavior. The Lua debug API asks for direct indexing
of frames, but the internal frame layout is a backwards linked
list. Since neither of these constraints is likely to change, the
workaround is going to stay.

--Mike

Other related posts: