summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-01-31 15:37:11 -0800
committerThiago Macieira <thiago.macieira@intel.com>2022-02-10 11:40:48 -0800
commit5be4c5aa0fca13d6bb397339766850cc806800ab (patch)
tree3ba89225f903f45b6750e35c28afbe9bc8cd16dd /src/corelib/tools/qhash.cpp
parent708de710f1ca9215ecb9ed2849e51c396a27129e (diff)
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>
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r--src/corelib/tools/qhash.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index c8cf1a496e..aca39c1be6 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -192,7 +192,7 @@ static HashSeedStorage qt_qhash_seed;
* Austin Appleby. See http://murmurhash.googlepages.com/
*/
#if QT_POINTER_SIZE == 4
-
+Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
static inline uint murmurhash(const void *key, uint len, uint seed) noexcept
{
// '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
-
+Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
static inline uint64_t murmurhash(const void *key, uint64_t len, uint64_t seed) noexcept
{
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); \
} 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)
{
/* "somepseudorandomlygeneratedbytes" */
@@ -434,7 +434,7 @@ static uint64_t siphash(const uint8_t *in, uint64_t inlen, uint64_t seed, uint64
v2 = ROTL(v2, 16); \
} while (0)
-
+Q_NEVER_INLINE Q_DECL_HOT_FUNCTION
static uint siphash(const uint8_t *in, uint inlen, uint seed, uint seed2)
{
/* "somepseudorandomlygeneratedbytes" */
@@ -793,6 +793,7 @@ size_t qHashBits(const void *p, size_t size, size_t seed) noexcept
# endif
return aeshash(reinterpret_cast<const uchar *>(p), size, seed, seed2);
#endif
+
if (size <= QT_POINTER_SIZE)
return murmurhash(p, size, seed);