Bug 1627618 - Part 8: Remove MBinaryArithInstruction which handles non-number specialisations. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 07 Apr 2020 08:37:56 +0000
changeset 522636 e14f372e1c71b9fad8dd9f36d2cf4d49556707d1
parent 522635 f37a78d235334c76a30bfb208f79646bc434027e
child 522637 13791501ae5dbd8f871846c275a96638117df11d
push id37293
push userapavel@mozilla.com
push dateTue, 07 Apr 2020 21:44:02 +0000
treeherdermozilla-central@de63e64b9090 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1627618
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1627618 - Part 8: Remove MBinaryArithInstruction which handles non-number specialisations. r=jandem The last part ensures that MBinaryArithInstruction always uses a number specialisation, so we can now remove any code which handles non-number specialisations for MBinaryArithInstruction. Differential Revision: https://phabricator.services.mozilla.com/D69788
js/src/jit/MIR.cpp
js/src/jit/MIR.h
js/src/jit/TypePolicy.cpp
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -2844,19 +2844,17 @@ MDefinition* MRsh::foldsTo(TempAllocator
       return MSignExtendInt32::New(alloc, lhs->getOperand(0),
                                    MSignExtendInt32::Byte);
   }
 
   return this;
 }
 
 MDefinition* MBinaryArithInstruction::foldsTo(TempAllocator& alloc) {
-  if (specialization_ == MIRType::None) {
-    return this;
-  }
+  MOZ_ASSERT(IsNumberType(specialization_));
 
   if (specialization_ == MIRType::Int64) {
     return this;
   }
 
   MDefinition* lhs = getOperand(0);
   MDefinition* rhs = getOperand(1);
   if (MConstant* folded = EvaluateConstantOperands(alloc, this)) {
@@ -2928,23 +2926,22 @@ bool MFilterTypeSet::canConsumeFloat32(M
   for (MUseDefIterator use(this); allConsumerUses && use; use++) {
     allConsumerUses &=
         !use.def()->isPhi() && use.def()->canConsumeFloat32(use.use());
   }
   return allConsumerUses;
 }
 
 void MBinaryArithInstruction::trySpecializeFloat32(TempAllocator& alloc) {
+  MOZ_ASSERT(IsNumberType(specialization_));
+
   // Do not use Float32 if we can use int32.
   if (specialization_ == MIRType::Int32) {
     return;
   }
-  if (specialization_ == MIRType::None) {
-    return;
-  }
 
   MDefinition* left = lhs();
   MDefinition* right = rhs();
 
   if (!left->canProduceFloat32() || !right->canProduceFloat32() ||
       !CheckUsesAreFloat32Consumers(this)) {
     if (left->type() == MIRType::Float32) {
       ConvertDefinitionToDouble<0>(alloc, left, this);
@@ -3151,19 +3148,17 @@ void MAbs::trySpecializeFloat32(TempAllo
     return;
   }
 
   setResultType(MIRType::Float32);
   specialization_ = MIRType::Float32;
 }
 
 MDefinition* MDiv::foldsTo(TempAllocator& alloc) {
-  if (specialization_ == MIRType::None) {
-    return this;
-  }
+  MOZ_ASSERT(IsNumberType(specialization_));
 
   if (specialization_ == MIRType::Int64) {
     return this;
   }
 
   if (MDefinition* folded = EvaluateConstantOperands(alloc, this)) {
     return folded;
   }
@@ -3217,19 +3212,17 @@ void MDiv::analyzeEdgeCasesBackward() {
   if (canBeNegativeZero() && !NeedNegativeZeroCheck(this)) {
     setCanBeNegativeZero(false);
   }
 }
 
 bool MDiv::fallible() const { return !isTruncated(); }
 
 MDefinition* MMod::foldsTo(TempAllocator& alloc) {
-  if (specialization_ == MIRType::None) {
-    return this;
-  }
+  MOZ_ASSERT(IsNumberType(specialization_));
 
   if (specialization_ == MIRType::Int64) {
     return this;
   }
 
   if (MDefinition* folded = EvaluateConstantOperands(alloc, this)) {
     return folded;
   }
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -4816,22 +4816,17 @@ class MBinaryArithInstruction : public M
 
   bool congruentTo(const MDefinition* ins) const override {
     if (!binaryCongruentTo(ins)) {
       return false;
     }
     const auto* other = static_cast<const MBinaryArithInstruction*>(ins);
     return other->mustPreserveNaN_ == mustPreserveNaN_;
   }
-  AliasSet getAliasSet() const override {
-    if (specialization_ >= MIRType::Object) {
-      return AliasSet::Store(AliasSet::Any);
-    }
-    return AliasSet::None();
-  }
+  AliasSet getAliasSet() const override { return AliasSet::None(); }
 
   bool isTruncated() const { return implicitTruncate_ == Truncate; }
   TruncateKind truncateKind() const { return implicitTruncate_; }
   void setTruncateKind(TruncateKind kind) {
     implicitTruncate_ = std::max(implicitTruncate_, kind);
   }
 };
 
@@ -5382,19 +5377,17 @@ class MAdd : public MBinaryArithInstruct
   bool fallible() const;
   void computeRange(TempAllocator& alloc) override;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
   TruncateKind operandTruncateKind(size_t index) const override;
 
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
-  bool canRecoverOnBailout() const override {
-    return specialization_ < MIRType::Object;
-  }
+  bool canRecoverOnBailout() const override { return true; }
 
   ALLOW_CLONE(MAdd)
 };
 
 class MSub : public MBinaryArithInstruction {
   MSub(MDefinition* left, MDefinition* right, MIRType type)
       : MBinaryArithInstruction(classOpcode, left, right, type) {}
 
@@ -5419,19 +5412,17 @@ class MSub : public MBinaryArithInstruct
   bool fallible() const;
   void computeRange(TempAllocator& alloc) override;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
   TruncateKind operandTruncateKind(size_t index) const override;
 
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
-  bool canRecoverOnBailout() const override {
-    return specialization_ < MIRType::Object;
-  }
+  bool canRecoverOnBailout() const override { return true; }
 
   ALLOW_CLONE(MSub)
 };
 
 class MMul : public MBinaryArithInstruction {
  public:
   enum Mode { Normal, Integer };
 
@@ -5505,32 +5496,28 @@ class MMul : public MBinaryArithInstruct
   void setCanBeNegativeZero(bool negativeZero) {
     canBeNegativeZero_ = negativeZero;
   }
 
   MOZ_MUST_USE bool updateForReplacement(MDefinition* ins) override;
 
   bool fallible() const { return canBeNegativeZero_ || canOverflow(); }
 
-  void setSpecialization(MIRType type) { specialization_ = type; }
-
   bool isFloat32Commutative() const override { return true; }
 
   void computeRange(TempAllocator& alloc) override;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
   TruncateKind operandTruncateKind(size_t index) const override;
 
   Mode mode() const { return mode_; }
 
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
-  bool canRecoverOnBailout() const override {
-    return specialization_ < MIRType::Object;
-  }
+  bool canRecoverOnBailout() const override { return true; }
 
   ALLOW_CLONE(MMul)
 };
 
 class MDiv : public MBinaryArithInstruction {
   bool canBeNegativeZero_;
   bool canBeNegativeOverflow_;
   bool canBeDivideByZero_;
@@ -5630,19 +5617,17 @@ class MDiv : public MBinaryArithInstruct
   bool fallible() const;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
   void collectRangeInfoPreTrunc() override;
   TruncateKind operandTruncateKind(size_t index) const override;
 
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
-  bool canRecoverOnBailout() const override {
-    return specialization_ < MIRType::Object;
-  }
+  bool canRecoverOnBailout() const override { return true; }
 
   bool congruentTo(const MDefinition* ins) const override {
     if (!MBinaryArithInstruction::congruentTo(ins)) {
       return false;
     }
     const MDiv* other = ins->toDiv();
     MOZ_ASSERT(other->trapOnError() == trapOnError_);
     return unsigned_ == other->isUnsigned();
@@ -5721,19 +5706,17 @@ class MMod : public MBinaryArithInstruct
   bool trapOnError() const { return trapOnError_; }
   wasm::BytecodeOffset bytecodeOffset() const {
     MOZ_ASSERT(bytecodeOffset_.isValid());
     return bytecodeOffset_;
   }
 
   MOZ_MUST_USE bool writeRecoverData(
       CompactBufferWriter& writer) const override;
-  bool canRecoverOnBailout() const override {
-    return specialization_ < MIRType::Object;
-  }
+  bool canRecoverOnBailout() const override { return true; }
 
   bool fallible() const;
 
   void computeRange(TempAllocator& alloc) override;
   bool needTruncation(TruncateKind kind) override;
   void truncate() override;
   void collectRangeInfoPreTrunc() override;
   TruncateKind operandTruncateKind(size_t index) const override;
--- a/js/src/jit/TypePolicy.cpp
+++ b/js/src/jit/TypePolicy.cpp
@@ -58,21 +58,17 @@ bool BoxInputsPolicy::staticAdjustInputs
       continue;
     }
     ins->replaceOperand(i, BoxAt(alloc, ins, in));
   }
   return true;
 }
 
 bool ArithPolicy::adjustInputs(TempAllocator& alloc, MInstruction* ins) const {
-  MIRType specialization = ins->typePolicySpecialization();
-  if (specialization == MIRType::None) {
-    return BoxInputsPolicy::staticAdjustInputs(alloc, ins);
-  }
-
+  MOZ_ASSERT(IsNumberType(ins->typePolicySpecialization()));
   MOZ_ASSERT(ins->type() == MIRType::Double || ins->type() == MIRType::Int32 ||
              ins->type() == MIRType::Float32);
 
   for (size_t i = 0, e = ins->numOperands(); i < e; i++) {
     MDefinition* in = ins->getOperand(i);
     if (in->type() == ins->type()) {
       continue;
     }