int lua_sethook (lua_State *L, lua_Hook f, int mask, int count);
The current API does not allow giving upvalues to the hook function from C API. This would be required in multithreading scenarios where several Lua states may be using the same lua_Hook function.
My current bypass is to tie a userdata via registry, but that registry access needs to be unwrapped each time the hook runs, which may be a lot.
Suggestion for future API:
int lua_sethook_x (lua_State *L, lua_Hook f, unsigned upvalues, int mask, int count);
#define lua_sethook(L,f,mask,count) lua_sethook_x(L,f,0,mask,count);
-asko