lua-users home
lua-l archive

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


Geoff Leyland wrote:
> On 4/04/2011, at 10:44 PM, Mike Pall wrote:
> > Lua 5.2 has an extra LUA_HOOKTAILCALL event. I can't use that for
> > LuaJIT, but I could pass the info in the line number. E.g. -1 for
> > regular calls and -2 for tail calls.
> 
> That'd be great!  Then I can just add a tailcall event to the
> collector and let the analyser work out the consequences.  It'd
> be different from the way Lua gets handled, but the two options
> are kind of orthogonal, so I wouldn't even need to know which I
> was tracing.

Oops, I just noticed I can't provide that info. The (tail)call has
already been performed when the hook is called.

Sorry, I guess you have to record the stack depth in the hook.
Note that it's sufficient to probe the outermost frame and one
below (one should be ok, the other not).

> I had imagined without any data that with LuaJIT a Lua hook
> might actually be faster than a C hook since there's potential
> for it to get compiled.  Is that not the case, and do you
> recommend a C hook?  It'd save me some benchmarking if you can
> point me one way or the other.

Hooks rarely contain loops, so they are rarely compiled. Note that
Lua hooks usually have more side-effects (e.g. on the GC). This
can lead to Heisenbugs. I'd opt for C hooks.

> Another question for later: is the timing measurement error for
> a profiler likely to change for VM and JITed code?

Well, the JIT compiled code doesn't call hooks ...

--Mike