[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuaJIT-2.0.0-beta1
- From: Mike Pall <mikelu-0911@...>
- Date: Sun, 8 Nov 2009 08:06:16 +0100
Geoff Leyland wrote:
> On some occasions, debug.info(depth) seems to return info about a
> different level of the stack frame in LJ2 than in Lua. I'm guessing you
> know this, and I think it's alluded to on the status page, but I thought
> I'd check. If it is new or of interest I'll try to make a short test
> Oh, it turns out that LJ1 behaves the same as LJ2, so I'm sure you
> already know.
This is probably about tail calls:
The LJ1/LJ2 debug calls always reflect the actual stack layout. A
tail call doesn't change the stack depth, neither for the actual
stack, nor when seen from the debug API.
The original Lua debug API adds fake stack levels for previously
executed tail calls. I have argued before that this is not helpful
for debuggers. It's not particularly useful either, as no info
about them can be returned. And it's hiding important language
semantics, too. Tail calls are a guaranteed feature in Lua, not
just an implementation detail.
Also, LJ2 applys the stack adjustment for tail calls consistently
for all function types, whereas the standard Lua interpreter
performs them after tail calls to C functions. This can affect the
output of something like 'return getfenv(1)'. IMHO it's debatable
which stack level this is supposed to refer to.