mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Use independent hash for VM event dispatch.
This commit is contained in:
parent
2ca58aa67d
commit
6667ab0f26
@ -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++);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user