summaryrefslogtreecommitdiff
path: root/src/lj_tab.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_tab.h')
-rw-r--r--src/lj_tab.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lj_tab.h b/src/lj_tab.h
index f8ace6c1..d18c604e 100644
--- a/src/lj_tab.h
+++ b/src/lj_tab.h
@@ -8,6 +8,21 @@
8 8
9#include "lj_obj.h" 9#include "lj_obj.h"
10 10
11/* Hash constants. Tuned using a brute force search. */
12#define HASH_BIAS (-0x04c11db7)
13#define HASH_ROT1 14
14#define HASH_ROT2 5
15#define HASH_ROT3 13
16
17/* Scramble the bits of numbers and pointers. */
18static LJ_AINLINE uint32_t hashrot(uint32_t lo, uint32_t hi)
19{
20 lo ^= hi; hi = lj_rol(hi, HASH_ROT1);
21 lo -= hi; hi = lj_rol(hi, HASH_ROT2);
22 hi ^= lo; hi -= lj_rol(lo, HASH_ROT3);
23 return hi;
24}
25
11#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0) 26#define hsize2hbits(s) ((s) ? ((s)==1 ? 1 : 1+lj_fls((uint32_t)((s)-1))) : 0)
12 27
13LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits); 28LJ_FUNCA GCtab *lj_tab_new(lua_State *L, uint32_t asize, uint32_t hbits);