提交 c971d8fa 编写于 作者: E Emilio G. Cota 提交者: Richard Henderson

exec: introduce qemu_xxhash{2,4,5,6,7}

Before moving them all to include/qemu/xxhash.h.
Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
Signed-off-by: NEmilio G. Cota <cota@braap.org>
Signed-off-by: NRichard Henderson <richard.henderson@linaro.org>
上级 e132fde2
...@@ -42,23 +42,23 @@ ...@@ -42,23 +42,23 @@
#define PRIME32_4 668265263U #define PRIME32_4 668265263U
#define PRIME32_5 374761393U #define PRIME32_5 374761393U
#define TB_HASH_XX_SEED 1 #define QEMU_XXHASH_SEED 1
/* /*
* xxhash32, customized for input variables that are not guaranteed to be * xxhash32, customized for input variables that are not guaranteed to be
* contiguous in memory. * contiguous in memory.
*/ */
static inline uint32_t static inline uint32_t
tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g)
{ {
uint32_t v1 = TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; uint32_t v1 = QEMU_XXHASH_SEED + PRIME32_1 + PRIME32_2;
uint32_t v2 = TB_HASH_XX_SEED + PRIME32_2; uint32_t v2 = QEMU_XXHASH_SEED + PRIME32_2;
uint32_t v3 = TB_HASH_XX_SEED + 0; uint32_t v3 = QEMU_XXHASH_SEED + 0;
uint32_t v4 = TB_HASH_XX_SEED - PRIME32_1; uint32_t v4 = QEMU_XXHASH_SEED - PRIME32_1;
uint32_t a = a0 >> 32; uint32_t a = ab >> 32;
uint32_t b = a0; uint32_t b = ab;
uint32_t c = b0 >> 32; uint32_t c = cd >> 32;
uint32_t d = b0; uint32_t d = cd;
uint32_t h32; uint32_t h32;
v1 += a * PRIME32_2; v1 += a * PRIME32_2;
...@@ -98,4 +98,25 @@ tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) ...@@ -98,4 +98,25 @@ tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g)
return h32; return h32;
} }
static inline uint32_t qemu_xxhash2(uint64_t ab)
{
return qemu_xxhash7(ab, 0, 0, 0, 0);
}
static inline uint32_t qemu_xxhash4(uint64_t ab, uint64_t cd)
{
return qemu_xxhash7(ab, cd, 0, 0, 0);
}
static inline uint32_t qemu_xxhash5(uint64_t ab, uint64_t cd, uint32_t e)
{
return qemu_xxhash7(ab, cd, e, 0, 0);
}
static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e,
uint32_t f)
{
return qemu_xxhash7(ab, cd, e, f, 0);
}
#endif /* EXEC_TB_HASH_XX_H */ #endif /* EXEC_TB_HASH_XX_H */
...@@ -61,7 +61,7 @@ static inline ...@@ -61,7 +61,7 @@ static inline
uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags, uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t flags,
uint32_t cf_mask, uint32_t trace_vcpu_dstate) uint32_t cf_mask, uint32_t trace_vcpu_dstate)
{ {
return tb_hash_func7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate);
} }
#endif #endif
...@@ -105,7 +105,7 @@ static bool is_equal(const void *ap, const void *bp) ...@@ -105,7 +105,7 @@ static bool is_equal(const void *ap, const void *bp)
static uint32_t h(unsigned long v) static uint32_t h(unsigned long v)
{ {
return tb_hash_func7(v, 0, 0, 0, 0); return qemu_xxhash2(v);
} }
static uint32_t hval(unsigned long v) static uint32_t hval(unsigned long v)
......
...@@ -135,13 +135,13 @@ QemuCondWaitFunc qemu_cond_wait_func = qemu_cond_wait_impl; ...@@ -135,13 +135,13 @@ QemuCondWaitFunc qemu_cond_wait_func = qemu_cond_wait_impl;
* without it we still get a pretty unique hash. * without it we still get a pretty unique hash.
*/ */
static inline static inline
uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t a) uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t ab)
{ {
uint64_t b = (uint64_t)(uintptr_t)callsite->obj; uint64_t cd = (uint64_t)(uintptr_t)callsite->obj;
uint32_t e = callsite->line; uint32_t e = callsite->line;
uint32_t f = callsite->type; uint32_t f = callsite->type;
return tb_hash_func7(a, b, e, f, 0); return qemu_xxhash6(ab, cd, e, f);
} }
static inline static inline
...@@ -169,11 +169,11 @@ static uint32_t qsp_entry_no_thread_hash(const QSPEntry *entry) ...@@ -169,11 +169,11 @@ static uint32_t qsp_entry_no_thread_hash(const QSPEntry *entry)
static uint32_t qsp_entry_no_thread_obj_hash(const QSPEntry *entry) static uint32_t qsp_entry_no_thread_obj_hash(const QSPEntry *entry)
{ {
const QSPCallSite *callsite = entry->callsite; const QSPCallSite *callsite = entry->callsite;
uint64_t a = g_str_hash(callsite->file); uint64_t ab = g_str_hash(callsite->file);
uint64_t b = callsite->line; uint64_t cd = callsite->line;
uint32_t e = callsite->type; uint32_t e = callsite->type;
return tb_hash_func7(a, b, e, 0, 0); return qemu_xxhash5(ab, cd, e);
} }
static bool qsp_callsite_cmp(const void *ap, const void *bp) static bool qsp_callsite_cmp(const void *ap, const void *bp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册