QHash: mark murmurhash() and siphash() hot and never-inline
Don't allow the compiler to inline them in qHashBits() because they require a lot of register use and add to the hot code path to aeshash(). Now all calls in this function are tail calls. Change-Id: I54f205f6b7314351b078fffd16cf7f2f97d99144 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
708de710f1
commit
5be4c5aa0f
@ -192,7 +192,7 @@ static HashSeedStorage qt_qhash_seed;
|
|||||||
* Austin Appleby. See http://murmurhash.googlepages.com/
|
* Austin Appleby. See http://murmurhash.googlepages.com/
|
||||||
*/
|
*/
|
||||||
#if QT_POINTER_SIZE == 4
|
#if QT_POINTER_SIZE == 4
|
||||||
|
Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
|
||||||
static inline uint murmurhash(const void *key, uint len, uint seed) noexcept
|
static inline uint murmurhash(const void *key, uint len, uint seed) noexcept
|
||||||
{
|
{
|
||||||
// 'm' and 'r' are mixing constants generated offline.
|
// 'm' and 'r' are mixing constants generated offline.
|
||||||
@ -250,7 +250,7 @@ static inline uint murmurhash(const void *key, uint len, uint seed) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
|
||||||
static inline uint64_t murmurhash(const void *key, uint64_t len, uint64_t seed) noexcept
|
static inline uint64_t murmurhash(const void *key, uint64_t len, uint64_t seed) noexcept
|
||||||
{
|
{
|
||||||
const uint64_t m = 0xc6a4a7935bd1e995ULL;
|
const uint64_t m = 0xc6a4a7935bd1e995ULL;
|
||||||
@ -329,7 +329,7 @@ static inline uint64_t murmurhash(const void *key, uint64_t len, uint64_t seed)
|
|||||||
v2 = ROTL(v2, 32); \
|
v2 = ROTL(v2, 32); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
|
||||||
static uint64_t siphash(const uint8_t *in, uint64_t inlen, uint64_t seed, uint64_t seed2)
|
static uint64_t siphash(const uint8_t *in, uint64_t inlen, uint64_t seed, uint64_t seed2)
|
||||||
{
|
{
|
||||||
/* "somepseudorandomlygeneratedbytes" */
|
/* "somepseudorandomlygeneratedbytes" */
|
||||||
@ -434,7 +434,7 @@ static uint64_t siphash(const uint8_t *in, uint64_t inlen, uint64_t seed, uint64
|
|||||||
v2 = ROTL(v2, 16); \
|
v2 = ROTL(v2, 16); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
|
||||||
static uint siphash(const uint8_t *in, uint inlen, uint seed, uint seed2)
|
static uint siphash(const uint8_t *in, uint inlen, uint seed, uint seed2)
|
||||||
{
|
{
|
||||||
/* "somepseudorandomlygeneratedbytes" */
|
/* "somepseudorandomlygeneratedbytes" */
|
||||||
@ -793,6 +793,7 @@ size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
|
|||||||
# endif
|
# endif
|
||||||
return aeshash(reinterpret_cast<const uchar *>(p), size, seed, seed2);
|
return aeshash(reinterpret_cast<const uchar *>(p), size, seed, seed2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (size <= QT_POINTER_SIZE)
|
if (size <= QT_POINTER_SIZE)
|
||||||
return murmurhash(p, size, seed);
|
return murmurhash(p, size, seed);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user