[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Disabling tail calls
- From: Ico <lua@...>
- Date: Thu, 30 Sep 2010 18:49:44 +0200
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 , 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 ?