diff options
author | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2009-12-08 19:46:35 +0100 |
commit | 55b16959717084884fd4a0cbae6d19e3786c20c7 (patch) | |
tree | c8a07a43c13679751ed25a9d06796e9e7b2134a6 /src/lj_vmevent.h | |
download | luajit-2.0.0-beta1.tar.gz luajit-2.0.0-beta1.tar.bz2 luajit-2.0.0-beta1.zip |
RELEASE LuaJIT-2.0.0-beta1v2.0.0-beta1
Diffstat (limited to '')
-rw-r--r-- | src/lj_vmevent.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lj_vmevent.h b/src/lj_vmevent.h new file mode 100644 index 00000000..9eaa52e1 --- /dev/null +++ b/src/lj_vmevent.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | ** VM event handling. | ||
3 | ** Copyright (C) 2005-2009 Mike Pall. See Copyright Notice in luajit.h | ||
4 | */ | ||
5 | |||
6 | #ifndef _LJ_VMEVENT_H | ||
7 | #define _LJ_VMEVENT_H | ||
8 | |||
9 | #include "lj_obj.h" | ||
10 | |||
11 | /* Registry key for VM event handler table. */ | ||
12 | #define LJ_VMEVENTS_REGKEY "_VMEVENTS" | ||
13 | #define LJ_VMEVENTS_HSIZE 4 | ||
14 | |||
15 | #define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) | ||
16 | #define VMEVENT_HASH(ev) ((int)(ev) & ~7) | ||
17 | #define VMEVENT_HASHIDX(h) ((int)(h) << 3) | ||
18 | #define VMEVENT_NOCACHE 255 | ||
19 | |||
20 | #define VMEVENT_DEF(name, hash) \ | ||
21 | LJ_VMEVENT_##name##_, \ | ||
22 | LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) | ||
23 | |||
24 | /* VM event IDs. */ | ||
25 | typedef enum { | ||
26 | VMEVENT_DEF(BC, 0x0000140b), | ||
27 | VMEVENT_DEF(TRACE, 0x10ea574d), | ||
28 | VMEVENT_DEF(RECORD, 0x5698231c), | ||
29 | VMEVENT_DEF(TEXIT, 0x12d984a7), | ||
30 | LJ_VMEVENT__MAX | ||
31 | } VMEvent; | ||
32 | |||
33 | #ifdef LUAJIT_DISABLE_VMEVENT | ||
34 | #define lj_vmevent_send(L, ev, args) UNUSED(L) | ||
35 | #else | ||
36 | #define lj_vmevent_send(L, ev, args) \ | ||
37 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ | ||
38 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ | ||
39 | if (argbase) { \ | ||
40 | args \ | ||
41 | lj_vmevent_call(L, argbase); \ | ||
42 | } \ | ||
43 | } | ||
44 | |||
45 | LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); | ||
46 | LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); | ||
47 | #endif | ||
48 | |||
49 | #endif | ||