Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/jemalloc/include/jemalloc/internal/hash.h
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | hash_x86_32(const void *key, int len, uint32_t seed) { | ||||
/* tail */ | /* tail */ | ||||
{ | { | ||||
const uint8_t *tail = (const uint8_t *) (data + nblocks*4); | const uint8_t *tail = (const uint8_t *) (data + nblocks*4); | ||||
uint32_t k1 = 0; | uint32_t k1 = 0; | ||||
switch (len & 3) { | switch (len & 3) { | ||||
case 3: k1 ^= tail[2] << 16; | case 3: k1 ^= tail[2] << 16; JEMALLOC_FALLTHROUGH | ||||
case 2: k1 ^= tail[1] << 8; | case 2: k1 ^= tail[1] << 8; JEMALLOC_FALLTHROUGH | ||||
case 1: k1 ^= tail[0]; k1 *= c1; k1 = hash_rotl_32(k1, 15); | case 1: k1 ^= tail[0]; k1 *= c1; k1 = hash_rotl_32(k1, 15); | ||||
k1 *= c2; h1 ^= k1; | k1 *= c2; h1 ^= k1; | ||||
} | } | ||||
} | } | ||||
/* finalization */ | /* finalization */ | ||||
h1 ^= len; | h1 ^= len; | ||||
h1 = hash_fmix_32(h1); | h1 = hash_fmix_32(h1); | ||||
return h1; | return h1; | ||||
} | } | ||||
UNUSED static inline void | static inline void | ||||
hash_x86_128(const void *key, const int len, uint32_t seed, | hash_x86_128(const void *key, const int len, uint32_t seed, | ||||
uint64_t r_out[2]) { | uint64_t r_out[2]) { | ||||
const uint8_t * data = (const uint8_t *) key; | const uint8_t * data = (const uint8_t *) key; | ||||
const int nblocks = len / 16; | const int nblocks = len / 16; | ||||
uint32_t h1 = seed; | uint32_t h1 = seed; | ||||
uint32_t h2 = seed; | uint32_t h2 = seed; | ||||
uint32_t h3 = seed; | uint32_t h3 = seed; | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | hash_x86_128(const void *key, const int len, uint32_t seed, | ||||
{ | { | ||||
const uint8_t *tail = (const uint8_t *) (data + nblocks*16); | const uint8_t *tail = (const uint8_t *) (data + nblocks*16); | ||||
uint32_t k1 = 0; | uint32_t k1 = 0; | ||||
uint32_t k2 = 0; | uint32_t k2 = 0; | ||||
uint32_t k3 = 0; | uint32_t k3 = 0; | ||||
uint32_t k4 = 0; | uint32_t k4 = 0; | ||||
switch (len & 15) { | switch (len & 15) { | ||||
case 15: k4 ^= tail[14] << 16; | case 15: k4 ^= tail[14] << 16; JEMALLOC_FALLTHROUGH | ||||
case 14: k4 ^= tail[13] << 8; | case 14: k4 ^= tail[13] << 8; JEMALLOC_FALLTHROUGH | ||||
case 13: k4 ^= tail[12] << 0; | case 13: k4 ^= tail[12] << 0; | ||||
k4 *= c4; k4 = hash_rotl_32(k4, 18); k4 *= c1; h4 ^= k4; | k4 *= c4; k4 = hash_rotl_32(k4, 18); k4 *= c1; h4 ^= k4; | ||||
JEMALLOC_FALLTHROUGH | |||||
case 12: k3 ^= tail[11] << 24; | case 12: k3 ^= tail[11] << 24; JEMALLOC_FALLTHROUGH | ||||
case 11: k3 ^= tail[10] << 16; | case 11: k3 ^= tail[10] << 16; JEMALLOC_FALLTHROUGH | ||||
case 10: k3 ^= tail[ 9] << 8; | case 10: k3 ^= tail[ 9] << 8; JEMALLOC_FALLTHROUGH | ||||
case 9: k3 ^= tail[ 8] << 0; | case 9: k3 ^= tail[ 8] << 0; | ||||
k3 *= c3; k3 = hash_rotl_32(k3, 17); k3 *= c4; h3 ^= k3; | k3 *= c3; k3 = hash_rotl_32(k3, 17); k3 *= c4; h3 ^= k3; | ||||
JEMALLOC_FALLTHROUGH | |||||
case 8: k2 ^= tail[ 7] << 24; | case 8: k2 ^= tail[ 7] << 24; JEMALLOC_FALLTHROUGH | ||||
case 7: k2 ^= tail[ 6] << 16; | case 7: k2 ^= tail[ 6] << 16; JEMALLOC_FALLTHROUGH | ||||
case 6: k2 ^= tail[ 5] << 8; | case 6: k2 ^= tail[ 5] << 8; JEMALLOC_FALLTHROUGH | ||||
case 5: k2 ^= tail[ 4] << 0; | case 5: k2 ^= tail[ 4] << 0; | ||||
k2 *= c2; k2 = hash_rotl_32(k2, 16); k2 *= c3; h2 ^= k2; | k2 *= c2; k2 = hash_rotl_32(k2, 16); k2 *= c3; h2 ^= k2; | ||||
JEMALLOC_FALLTHROUGH | |||||
case 4: k1 ^= tail[ 3] << 24; | case 4: k1 ^= tail[ 3] << 24; JEMALLOC_FALLTHROUGH | ||||
case 3: k1 ^= tail[ 2] << 16; | case 3: k1 ^= tail[ 2] << 16; JEMALLOC_FALLTHROUGH | ||||
case 2: k1 ^= tail[ 1] << 8; | case 2: k1 ^= tail[ 1] << 8; JEMALLOC_FALLTHROUGH | ||||
case 1: k1 ^= tail[ 0] << 0; | case 1: k1 ^= tail[ 0] << 0; | ||||
k1 *= c1; k1 = hash_rotl_32(k1, 15); k1 *= c2; h1 ^= k1; | k1 *= c1; k1 = hash_rotl_32(k1, 15); k1 *= c2; h1 ^= k1; | ||||
break; | |||||
} | } | ||||
} | } | ||||
/* finalization */ | /* finalization */ | ||||
h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; | h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len; | ||||
h1 += h2; h1 += h3; h1 += h4; | h1 += h2; h1 += h3; h1 += h4; | ||||
h2 += h1; h3 += h1; h4 += h1; | h2 += h1; h3 += h1; h4 += h1; | ||||
h1 = hash_fmix_32(h1); | h1 = hash_fmix_32(h1); | ||||
h2 = hash_fmix_32(h2); | h2 = hash_fmix_32(h2); | ||||
h3 = hash_fmix_32(h3); | h3 = hash_fmix_32(h3); | ||||
h4 = hash_fmix_32(h4); | h4 = hash_fmix_32(h4); | ||||
h1 += h2; h1 += h3; h1 += h4; | h1 += h2; h1 += h3; h1 += h4; | ||||
h2 += h1; h3 += h1; h4 += h1; | h2 += h1; h3 += h1; h4 += h1; | ||||
r_out[0] = (((uint64_t) h2) << 32) | h1; | r_out[0] = (((uint64_t) h2) << 32) | h1; | ||||
r_out[1] = (((uint64_t) h4) << 32) | h3; | r_out[1] = (((uint64_t) h4) << 32) | h3; | ||||
} | } | ||||
UNUSED static inline void | static inline void | ||||
hash_x64_128(const void *key, const int len, const uint32_t seed, | hash_x64_128(const void *key, const int len, const uint32_t seed, | ||||
uint64_t r_out[2]) { | uint64_t r_out[2]) { | ||||
const uint8_t *data = (const uint8_t *) key; | const uint8_t *data = (const uint8_t *) key; | ||||
const int nblocks = len / 16; | const int nblocks = len / 16; | ||||
uint64_t h1 = seed; | uint64_t h1 = seed; | ||||
uint64_t h2 = seed; | uint64_t h2 = seed; | ||||
Show All 23 Lines | hash_x64_128(const void *key, const int len, const uint32_t seed, | ||||
/* tail */ | /* tail */ | ||||
{ | { | ||||
const uint8_t *tail = (const uint8_t*)(data + nblocks*16); | const uint8_t *tail = (const uint8_t*)(data + nblocks*16); | ||||
uint64_t k1 = 0; | uint64_t k1 = 0; | ||||
uint64_t k2 = 0; | uint64_t k2 = 0; | ||||
switch (len & 15) { | switch (len & 15) { | ||||
case 15: k2 ^= ((uint64_t)(tail[14])) << 48; /* falls through */ | case 15: k2 ^= ((uint64_t)(tail[14])) << 48; JEMALLOC_FALLTHROUGH | ||||
case 14: k2 ^= ((uint64_t)(tail[13])) << 40; /* falls through */ | case 14: k2 ^= ((uint64_t)(tail[13])) << 40; JEMALLOC_FALLTHROUGH | ||||
case 13: k2 ^= ((uint64_t)(tail[12])) << 32; /* falls through */ | case 13: k2 ^= ((uint64_t)(tail[12])) << 32; JEMALLOC_FALLTHROUGH | ||||
case 12: k2 ^= ((uint64_t)(tail[11])) << 24; /* falls through */ | case 12: k2 ^= ((uint64_t)(tail[11])) << 24; JEMALLOC_FALLTHROUGH | ||||
case 11: k2 ^= ((uint64_t)(tail[10])) << 16; /* falls through */ | case 11: k2 ^= ((uint64_t)(tail[10])) << 16; JEMALLOC_FALLTHROUGH | ||||
case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8; /* falls through */ | case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8; JEMALLOC_FALLTHROUGH | ||||
case 9: k2 ^= ((uint64_t)(tail[ 8])) << 0; | case 9: k2 ^= ((uint64_t)(tail[ 8])) << 0; | ||||
k2 *= c2; k2 = hash_rotl_64(k2, 33); k2 *= c1; h2 ^= k2; | k2 *= c2; k2 = hash_rotl_64(k2, 33); k2 *= c1; h2 ^= k2; | ||||
/* falls through */ | JEMALLOC_FALLTHROUGH | ||||
case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56; /* falls through */ | case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56; JEMALLOC_FALLTHROUGH | ||||
case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48; /* falls through */ | case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48; JEMALLOC_FALLTHROUGH | ||||
case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40; /* falls through */ | case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40; JEMALLOC_FALLTHROUGH | ||||
case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32; /* falls through */ | case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32; JEMALLOC_FALLTHROUGH | ||||
case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24; /* falls through */ | case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24; JEMALLOC_FALLTHROUGH | ||||
case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16; /* falls through */ | case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16; JEMALLOC_FALLTHROUGH | ||||
case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8; /* falls through */ | case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8; JEMALLOC_FALLTHROUGH | ||||
case 1: k1 ^= ((uint64_t)(tail[ 0])) << 0; | case 1: k1 ^= ((uint64_t)(tail[ 0])) << 0; | ||||
k1 *= c1; k1 = hash_rotl_64(k1, 31); k1 *= c2; h1 ^= k1; | k1 *= c1; k1 = hash_rotl_64(k1, 31); k1 *= c2; h1 ^= k1; | ||||
} | } | ||||
} | } | ||||
/* finalization */ | /* finalization */ | ||||
h1 ^= len; h2 ^= len; | h1 ^= len; h2 ^= len; | ||||
Show All 32 Lines |