lua-users home
lua-l archive

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


Hi all,

For debugging purposes I'd like to - temporarily - disable tail calls in my
code to get more sensible stack traces.  I'm working on a fairly big
application (+40K lines of code) which reaches stacks of 20 or more levels
deep, and when half of them show 'tail call', it is not always easy to follow
what is happening. Simply altering the code to avoid tail call optimization is
not an option, because there is a lot of code involved, and I would still like
to be able to get the performance benefits of tail calls in production.

I found a post from Rici Lake discussing this subject from 2003 [1], which
shows a pretty detailed solution by adding a lua function for disabling and
enabling tail calls on the fly. Of course this does no longer apply to the
current Lua code, but as far as I understand it would be trivial to make a
similar modification to the latest Lua version.

My current solution is to have a patched lua interpreter/compiler at hand with
a small modification to treat OP_TAILCALL simply as OP_CALL, but I think the
original proposal from Rici might be worth reconsidering.

Any opinions ?


[1] http://lua-users.org/lists/lua-l/2003-10/msg00005.html


-- 
:wq
^X^Cy^K^X^C^C^C^C