diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index ead13b1a4459..3b63592bae92 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -174,14 +174,18 @@ MDefinition::printName(FILE *fp) const fprintf(fp, "%u", id()); } +HashNumber +MDefinition::addU32ToHash(HashNumber hash, uint32_t data) +{ + return data + (hash << 6) + (hash << 16) - hash; +} + HashNumber MDefinition::valueHash() const { HashNumber out = op(); - for (size_t i = 0, e = numOperands(); i < e; i++) { - uint32_t valueNumber = getOperand(i)->id(); - out = valueNumber + (out << 6) + (out << 16) - out; - } + for (size_t i = 0, e = numOperands(); i < e; i++) + out = addU32ToHash(out, getOperand(i)->id()); return out; } @@ -686,7 +690,9 @@ MParameter::printOpcode(FILE *fp) const HashNumber MParameter::valueHash() const { - return index_; // Why not? + HashNumber hash = MDefinition::valueHash(); + hash = addU32ToHash(hash, index_); + return hash; } bool @@ -2866,6 +2872,14 @@ MAsmJSLoadGlobalVar::mightAlias(const MDefinition *def) const return true; } +HashNumber +MAsmJSLoadGlobalVar::valueHash() const +{ + HashNumber hash = MDefinition::valueHash(); + hash = addU32ToHash(hash, globalDataOffset_); + return hash; +} + bool MAsmJSLoadGlobalVar::congruentTo(const MDefinition *ins) const { @@ -2876,6 +2890,42 @@ MAsmJSLoadGlobalVar::congruentTo(const MDefinition *ins) const return false; } +HashNumber +MAsmJSLoadFuncPtr::valueHash() const +{ + HashNumber hash = MDefinition::valueHash(); + hash = addU32ToHash(hash, globalDataOffset_); + return hash; +} + +bool +MAsmJSLoadFuncPtr::congruentTo(const MDefinition *ins) const +{ + if (ins->isAsmJSLoadFuncPtr()) { + const MAsmJSLoadFuncPtr *load = ins->toAsmJSLoadFuncPtr(); + return globalDataOffset_ == load->globalDataOffset_; + } + return false; +} + +HashNumber +MAsmJSLoadFFIFunc::valueHash() const +{ + HashNumber hash = MDefinition::valueHash(); + hash = addU32ToHash(hash, globalDataOffset_); + return hash; +} + +bool +MAsmJSLoadFFIFunc::congruentTo(const MDefinition *ins) const +{ + if (ins->isAsmJSLoadFFIFunc()) { + const MAsmJSLoadFFIFunc *load = ins->toAsmJSLoadFFIFunc(); + return globalDataOffset_ == load->globalDataOffset_; + } + return false; +} + bool MLoadSlot::mightAlias(const MDefinition *store) const { @@ -2884,6 +2934,14 @@ MLoadSlot::mightAlias(const MDefinition *store) const return true; } +HashNumber +MLoadSlot::valueHash() const +{ + HashNumber hash = MDefinition::valueHash(); + hash = addU32ToHash(hash, slot_); + return hash; +} + bool MGuardShapePolymorphic::congruentTo(const MDefinition *ins) const { diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 18871e12015b..273857f13912 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -360,6 +360,8 @@ class MDefinition : public MNode block_ = block; } + static HashNumber addU32ToHash(HashNumber hash, uint32_t data); + public: MDefinition() : id_(0), @@ -8111,6 +8113,7 @@ class MLoadSlot return slot_; } + HashNumber valueHash() const; bool congruentTo(const MDefinition *ins) const { if (!ins->isLoadSlot()) return false; @@ -10402,6 +10405,7 @@ class MAsmJSLoadGlobalVar : public MNullaryInstruction unsigned globalDataOffset() const { return globalDataOffset_; } + HashNumber valueHash() const; bool congruentTo(const MDefinition *ins) const; AliasSet getAliasSet() const { @@ -10455,6 +10459,9 @@ class MAsmJSLoadFuncPtr : public MUnaryInstruction unsigned globalDataOffset() const { return globalDataOffset_; } MDefinition *index() const { return getOperand(0); } + + HashNumber valueHash() const; + bool congruentTo(const MDefinition *ins) const; }; class MAsmJSLoadFFIFunc : public MNullaryInstruction @@ -10476,6 +10483,9 @@ class MAsmJSLoadFFIFunc : public MNullaryInstruction } unsigned globalDataOffset() const { return globalDataOffset_; } + + HashNumber valueHash() const; + bool congruentTo(const MDefinition *ins) const; }; class MAsmJSParameter : public MNullaryInstruction