summaryrefslogtreecommitdiff
path: root/src/lj_record.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-01-19 02:05:37 +0100
committerMike Pall <mike>2011-01-19 02:05:37 +0100
commit6bce6b118eeb2bb7f36157de158e5cccf0ea68e5 (patch)
tree30a29f68e2f8841d409972af330efb5081705511 /src/lj_record.c
parentd20e53c322332f8197f401d6125f48071488b711 (diff)
downloadluajit-6bce6b118eeb2bb7f36157de158e5cccf0ea68e5.tar.gz
luajit-6bce6b118eeb2bb7f36157de158e5cccf0ea68e5.tar.bz2
luajit-6bce6b118eeb2bb7f36157de158e5cccf0ea68e5.zip
Add compile-time option LUAJIT_ENABLE_CHECKHOOK. Disabled by default.
This checks for asynchronously set hooks from compiled code.
Diffstat (limited to 'src/lj_record.c')
-rw-r--r--src/lj_record.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lj_record.c b/src/lj_record.c
index 90779f92..f1dd8e3e 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -2033,6 +2033,27 @@ void lj_record_setup(jit_State *J)
2033 if (1 + J->pt->framesize >= LJ_MAX_JSLOTS) 2033 if (1 + J->pt->framesize >= LJ_MAX_JSLOTS)
2034 lj_trace_err(J, LJ_TRERR_STACKOV); 2034 lj_trace_err(J, LJ_TRERR_STACKOV);
2035 } 2035 }
2036#ifdef LUAJIT_ENABLE_CHECKHOOK
2037 /* Regularly check for instruction/line hooks from compiled code and
2038 ** exit to the interpreter if the hooks are set.
2039 **
2040 ** This is a compile-time option and disabled by default, since the
2041 ** hook checks may be quite expensive in tight loops.
2042 **
2043 ** Note this is only useful if hooks are *not* set most of the time.
2044 ** Use this only if you want to *asynchronously* interrupt the execution.
2045 **
2046 ** You can set the instruction hook via lua_sethook() with a count of 1
2047 ** from a signal handler or another native thread. Please have a look
2048 ** at the first few functions in luajit.c for an example (Ctrl-C handler).
2049 */
2050 {
2051 TRef tr = emitir(IRT(IR_XLOAD, IRT_U8),
2052 lj_ir_kptr(J, &J2G(J)->hookmask), IRXLOAD_VOLATILE);
2053 tr = emitir(IRTI(IR_BAND), tr, lj_ir_kint(J, (LUA_MASKLINE|LUA_MASKCOUNT)));
2054 emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, 0));
2055 }
2056#endif
2036} 2057}
2037 2058
2038#undef IR 2059#undef IR