Use independent hash for VM event dispatch.

This commit is contained in:
Mike Pall 2010-07-21 21:23:45 +02:00
parent 2ca58aa67d
commit 6667ab0f26
2 changed files with 8 additions and 5 deletions

View File

@ -114,8 +114,11 @@ LJLIB_CF(jit_attach)
GCstr *s = lj_lib_optstr(L, 2);
luaL_findtable(L, LUA_REGISTRYINDEX, LJ_VMEVENTS_REGKEY, LJ_VMEVENTS_HSIZE);
if (s) { /* Attach to given event. */
const uint8_t *p = (const uint8_t *)strdata(s);
uint32_t h = s->len;
while (*p) h = h ^ (lj_rol(h, 6) + *p++);
lua_pushvalue(L, 1);
lua_rawseti(L, -2, VMEVENT_HASHIDX(s->hash));
lua_rawseti(L, -2, VMEVENT_HASHIDX(h));
G(L)->vmevmask = VMEVENT_NOCACHE; /* Invalidate cache. */
} else { /* Detach if no event given. */
setnilV(L->top++);

View File

@ -23,10 +23,10 @@
/* VM event IDs. */
typedef enum {
VMEVENT_DEF(BC, 0x0000140b),
VMEVENT_DEF(TRACE, 0x10ea574d),
VMEVENT_DEF(RECORD, 0x5698231c),
VMEVENT_DEF(TEXIT, 0x12d984a7),
VMEVENT_DEF(BC, 0x00003883),
VMEVENT_DEF(TRACE, 0xb2d91467),
VMEVENT_DEF(RECORD, 0x9284bf4f),
VMEVENT_DEF(TEXIT, 0xb29df2b0),
LJ_VMEVENT__MAX
} VMEvent;