mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
Add compile-time option LUAJIT_ENABLE_CHECKHOOK. Disabled by default.
This checks for asynchronously set hooks from compiled code.
This commit is contained in:
parent
d20e53c322
commit
6bce6b118e
@ -2033,6 +2033,27 @@ void lj_record_setup(jit_State *J)
|
||||
if (1 + J->pt->framesize >= LJ_MAX_JSLOTS)
|
||||
lj_trace_err(J, LJ_TRERR_STACKOV);
|
||||
}
|
||||
#ifdef LUAJIT_ENABLE_CHECKHOOK
|
||||
/* Regularly check for instruction/line hooks from compiled code and
|
||||
** exit to the interpreter if the hooks are set.
|
||||
**
|
||||
** This is a compile-time option and disabled by default, since the
|
||||
** hook checks may be quite expensive in tight loops.
|
||||
**
|
||||
** Note this is only useful if hooks are *not* set most of the time.
|
||||
** Use this only if you want to *asynchronously* interrupt the execution.
|
||||
**
|
||||
** You can set the instruction hook via lua_sethook() with a count of 1
|
||||
** from a signal handler or another native thread. Please have a look
|
||||
** at the first few functions in luajit.c for an example (Ctrl-C handler).
|
||||
*/
|
||||
{
|
||||
TRef tr = emitir(IRT(IR_XLOAD, IRT_U8),
|
||||
lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE);
|
||||
tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT)));
|
||||
emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef IR
|
||||
|
Loading…
Reference in New Issue
Block a user