On Wed, Apr 12, 2017 at 11:46:47 +0800, Paolo Bonzini wrote:
>
>
> On 12/04/2017 09:17, Emilio G. Cota wrote:
> > +
> > +/* 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);
> > +}
>
> What about multiplicative hashing?
>
> return (uint64_t) (pc * 2654435761) >> 32;
I tested this one, taking the TB_JMP_CACHE_SIZE-1 lower bits of
the result:
http://imgur.com/QIhm875
In terms of quality it's good (I profile hit rates and they're all
pretty good), but shift+xor are just so hard to beat: shift+xor
take 1 cycle each; the multiplication takes on my machine 3 or 4
cycles (source: Fog's tables).
Thanks,
E.