Joey.Luo
Joey.Luo

Reputation: 89

luajit can't hook "tail return"

We know Lua has a library function debug.sethook, when any function return,
the hook function be called with event "return" or "tail return", but LuaJIT do not hook "tail return".
Is there any methods to turn off the specialization of LuaJIT, and let it hook "tail return"?

Upvotes: 1

Views: 773

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26794

It's a "feature" of LuaJIT implementation, so it's not likely that you can turn it off. As the author of LuaJIT suggested, you can track stack depth in the hook, but you won't be able to specifically track tail call returns.

Note that Lua also moved from tail returns to tail calls: "For call events, event can be LUA_HOOKCALL, the normal value, or LUA_HOOKTAILCALL, for a tail call; in this case, there will be no corresponding return event."

Upvotes: 0

Related Questions