Bug 1058075 - IonMonkey: GVN: Fix MConstant's hash function to reduce collisions r=mjrosenb

This commit is contained in:
Dan Gohman 2014-08-25 15:03:23 -07:00
parent a933f2da69
commit 1c3d6b8f1e

View File

@ -542,10 +542,14 @@ MConstant::MConstant(JSObject *obj)
HashNumber
MConstant::valueHash() const
{
// This disregards some state, since values are 64 bits. But for a hash,
// it's completely acceptable.
return (HashNumber)JSVAL_TO_IMPL(value_).asBits;
// Fold all 64 bits into the 32-bit result. It's tempting to just discard
// half of the bits, as this is just a hash, however there are many common
// patterns of values where only the low or the high bits vary, so
// discarding either side would lead to excessive hash collisions.
uint64_t bits = JSVAL_TO_IMPL(value_).asBits;
return (HashNumber)bits ^ (HashNumber)(bits >> 32);
}
bool
MConstant::congruentTo(const MDefinition *ins) const
{