diff options
author | Mike Pall <mike> | 2010-07-21 21:23:45 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2010-07-21 21:23:45 +0200 |
commit | 6667ab0f266b12909cf0eedd025525b24d987592 (patch) | |
tree | f7ae3500eac3fda50f347cf6344035545e02a400 /src | |
parent | 2ca58aa67d68076f8980395f45ce1215875fc0fc (diff) | |
download | luajit-6667ab0f266b12909cf0eedd025525b24d987592.tar.gz luajit-6667ab0f266b12909cf0eedd025525b24d987592.tar.bz2 luajit-6667ab0f266b12909cf0eedd025525b24d987592.zip |
Use independent hash for VM event dispatch.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib_jit.c | 5 | ||||
-rw-r--r-- | src/lj_vmevent.h | 8 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 033ab4c4..4cabb2f7 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -114,8 +114,11 @@ LJLIB_CF(jit_attach) | |||
114 | GCstr *s = lj_lib_optstr(L, 2); | 114 | GCstr *s = lj_lib_optstr(L, 2); |
115 | luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); | 115 | luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE); |
116 | if (s) { /* Attach to given event. */ | 116 | if (s) { /* Attach to given event. */ |
117 | const uint8_t *p = (const uint8_t *)strdata(s); | ||
118 | uint32_t h = s->len; | ||
119 | while (*p) h = h ^ (lj_rol(h, 6) + *p++); | ||
117 | lua_pushvalue(L, 1); | 120 | lua_pushvalue(L, 1); |
118 | lua_rawseti(L, -2, VMEVENT_HASHIDX(s->hash)); | 121 | lua_rawseti(L, -2, VMEVENT_HASHIDX(h)); |
119 | G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ | 122 | G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */ |
120 | } else { /* Detach if no event given. */ | 123 | } else { /* Detach if no event given. */ |
121 | setnilV(L->top++); | 124 | setnilV(L->top++); |
diff --git a/src/lj_vmevent.h b/src/lj_vmevent.h index ceb70f82..9d21cb1e 100644 --- a/src/lj_vmevent.h +++ b/src/lj_vmevent.h | |||
@@ -23,10 +23,10 @@ | |||
23 | 23 | ||
24 | /* VM event IDs. */ | 24 | /* VM event IDs. */ |
25 | typedef enum { | 25 | typedef enum { |
26 | VMEVENT_DEF(BC, 0x0000140b), | 26 | VMEVENT_DEF(BC, 0x00003883), |
27 | VMEVENT_DEF(TRACE, 0x10ea574d), | 27 | VMEVENT_DEF(TRACE, 0xb2d91467), |
28 | VMEVENT_DEF(RECORD, 0x5698231c), | 28 | VMEVENT_DEF(RECORD, 0x9284bf4f), |
29 | VMEVENT_DEF(TEXIT, 0x12d984a7), | 29 | VMEVENT_DEF(TEXIT, 0xb29df2b0), |
30 | LJ_VMEVENT__MAX | 30 | LJ_VMEVENT__MAX |
31 | } VMEvent; | 31 | } VMEvent; |
32 | 32 | ||