diff --git a/qemu/include/exec/tb-hash.h b/qemu/include/exec/tb-hash.h index e645ff5e..f4b4fb74 100644 --- a/qemu/include/exec/tb-hash.h +++ b/qemu/include/exec/tb-hash.h @@ -23,6 +23,8 @@ #include "exec/exec-all.h" #include "exec/tb-hash-xx.h" +#ifdef CONFIG_SOFTMMU + /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for addresses on the same page. The top bits are the same. This allows TLB invalidation to quickly clear a subset of the hash table. */ @@ -38,6 +40,16 @@ static inline unsigned int tb_jmp_cache_hash_page(target_ulong pc) return (tmp >> (TARGET_PAGE_BITS - TB_JMP_PAGE_BITS)) & TB_JMP_PAGE_MASK; } +#else + +/* In user-mode we can get better hashing because we do not have a TLB */ +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) +{ + return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1); +} + +#endif /* CONFIG_SOFTMMU */ + static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) { target_ulong tmp;