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++);