Bug 1627618 - Part 16: Remove MBinaryBitwiseInstruction::specializeAs. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Tue, 07 Apr 2020 08:41:22 +0000
changeset 522661 1d50b0cf715856e5e86535040bbf8cf883c01920
parent 522660 cfdd8f0aa45cbc08492f37e52bc6c70a11f894a7
child 522662 e3738b70e2704d8186cc3da20e8948d0250fb098
push id112239
push userccoroiu@mozilla.com
push dateTue, 07 Apr 2020 15:04:11 +0000
treeherderautoland@5b653e25e757 [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 16: Remove MBinaryBitwiseInstruction::specializeAs. r=jandem Remove `MBinaryBitwiseInstruction::specializeAs()` and instead directly set the specialisation in the `MBinaryBitwiseInstruction` constructor. For BitAnd, BitOr, and BitXor also set the "commutative" flag in the constructor. Differential Revision: https://phabricator.services.mozilla.com/D69796
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -2527,29 +2527,16 @@ MDefinition* MBinaryBitwiseInstruction::
     MOZ_ASSERT(rhs->isConstant());
     MOZ_ASSERT(rhs->type() == MIRType::Int32);
     return foldIfAllBitsSet(1);
   }
 
   return this;
 }
 
-void MBinaryBitwiseInstruction::specializeAs(MIRType type) {
-  MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64 ||
-             (isUrsh() && type == MIRType::Double));
-  MOZ_ASSERT(this->type() == MIRType::Value || this->type() == type);
-
-  specialization_ = type;
-  setResultType(type);
-
-  if (isBitOr() || isBitAnd() || isBitXor()) {
-    setCommutative();
-  }
-}
-
 static inline bool CanProduceNegativeZero(MDefinition* def) {
   // Test if this instruction can produce negative zero even when bailing out
   // and changing types.
   switch (def->op()) {
     case MDefinition::Opcode::Constant:
       if (def->type() == MIRType::Double &&
           def->toConstant()->toDouble() == -0.0) {
         return true;
@@ -3594,62 +3581,19 @@ void MTypeOf::cacheInputMaybeCallableOrE
   MOZ_ASSERT(inputMaybeCallableOrEmulatesUndefined());
 
   if (!input()->maybeEmulatesUndefined(constraints) &&
       !MaybeCallable(constraints, input())) {
     markInputNotCallableOrEmulatesUndefined();
   }
 }
 
-MBitAnd* MBitAnd::New(TempAllocator& alloc, MDefinition* left,
-                      MDefinition* right, MIRType type) {
-  MBitAnd* ins = new (alloc) MBitAnd(left, right, type);
-  ins->specializeAs(type);
-  return ins;
-}
-
-MBitOr* MBitOr::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                    MIRType type) {
-  MBitOr* ins = new (alloc) MBitOr(left, right, type);
-  ins->specializeAs(type);
-  return ins;
-}
-
-MBitXor* MBitXor::New(TempAllocator& alloc, MDefinition* left,
-                      MDefinition* right, MIRType type) {
-  MBitXor* ins = new (alloc) MBitXor(left, right, type);
-  ins->specializeAs(type);
-  return ins;
-}
-
-MLsh* MLsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                MIRType type) {
-  MLsh* ins = new (alloc) MLsh(left, right, type);
-  ins->specializeAs(type);
-  return ins;
-}
-
-MRsh* MRsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                MIRType type) {
-  MRsh* ins = new (alloc) MRsh(left, right, type);
-  ins->specializeAs(type);
-  return ins;
-}
-
-MUrsh* MUrsh::New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                  MIRType type) {
-  MUrsh* ins = new (alloc) MUrsh(left, right, MIRType::Int32);
-  ins->specializeAs(type);
-  return ins;
-}
-
 MUrsh* MUrsh::NewWasm(TempAllocator& alloc, MDefinition* left,
                       MDefinition* right, MIRType type) {
   MUrsh* ins = new (alloc) MUrsh(left, right, type);
-  ins->specializeAs(type);
 
   // Since Ion has no UInt32 type, we use Int32 and we have a special
   // exception to the type rules: we can return values in
   // (INT32_MIN,UINT32_MAX] and still claim that we have an Int32 type
   // without bailing out. This is necessary because Ion has no UInt32
   // type and we can't have bailouts in wasm code.
   ins->bailoutsDisabled_ = true;
 
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -4450,22 +4450,23 @@ class MToId : public MUnaryInstruction, 
 class MBinaryBitwiseInstruction : public MBinaryInstruction,
                                   public BitwisePolicy::Data {
  protected:
   MBinaryBitwiseInstruction(Opcode op, MDefinition* left, MDefinition* right,
                             MIRType type)
       : MBinaryInstruction(op, left, right),
         maskMatchesLeftRange(false),
         maskMatchesRightRange(false) {
-    MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64);
-    setResultType(MIRType::Value);
-    setMovable();
-  }
-
-  void specializeAs(MIRType type);
+    MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64 ||
+               (isUrsh() && type == MIRType::Double));
+    specialization_ = type;
+    setResultType(type);
+    setMovable();
+  }
+
   bool maskMatchesLeftRange;
   bool maskMatchesRightRange;
 
  public:
   MDefinition* foldsTo(TempAllocator& alloc) override;
   MDefinition* foldUnnecessaryBitop();
   virtual MDefinition* foldIfZero(size_t operand) = 0;
   virtual MDefinition* foldIfNegOne(size_t operand) = 0;
@@ -4488,22 +4489,23 @@ class MBinaryBitwiseInstruction : public
     return AliasSet::None();
   }
 
   TruncateKind operandTruncateKind(size_t index) const override;
 };
 
 class MBitAnd : public MBinaryBitwiseInstruction {
   MBitAnd(MDefinition* left, MDefinition* right, MIRType type)
-      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
+      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {
+    setCommutative();
+  }
 
  public:
   INSTRUCTION_HEADER(BitAnd)
-  static MBitAnd* New(TempAllocator& alloc, MDefinition* left,
-                      MDefinition* right, MIRType type);
+  TRIVIAL_NEW_WRAPPERS
 
   MDefinition* foldIfZero(size_t operand) override {
     return getOperand(operand);  // 0 & x => 0;
   }
   MDefinition* foldIfNegOne(size_t operand) override {
     return getOperand(1 - operand);  // x & -1 => x
   }
   MDefinition* foldIfEqual() override {
@@ -4521,22 +4523,23 @@ class MBitAnd : public MBinaryBitwiseIns
     return specialization_ != MIRType::None;
   }
 
   ALLOW_CLONE(MBitAnd)
 };
 
 class MBitOr : public MBinaryBitwiseInstruction {
   MBitOr(MDefinition* left, MDefinition* right, MIRType type)
-      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
+      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {
+    setCommutative();
+  }
 
  public:
   INSTRUCTION_HEADER(BitOr)
-  static MBitOr* New(TempAllocator& alloc, MDefinition* left,
-                     MDefinition* right, MIRType type);
+  TRIVIAL_NEW_WRAPPERS
 
   MDefinition* foldIfZero(size_t operand) override {
     return getOperand(1 -
                       operand);  // 0 | x => x, so if ith is 0, return (1-i)th
   }
   MDefinition* foldIfNegOne(size_t operand) override {
     return getOperand(operand);  // x | -1 => -1
   }
@@ -4551,22 +4554,23 @@ class MBitOr : public MBinaryBitwiseInst
     return specialization_ != MIRType::None;
   }
 
   ALLOW_CLONE(MBitOr)
 };
 
 class MBitXor : public MBinaryBitwiseInstruction {
   MBitXor(MDefinition* left, MDefinition* right, MIRType type)
-      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {}
+      : MBinaryBitwiseInstruction(classOpcode, left, right, type) {
+    setCommutative();
+  }
 
  public:
   INSTRUCTION_HEADER(BitXor)
-  static MBitXor* New(TempAllocator& alloc, MDefinition* left,
-                      MDefinition* right, MIRType type);
+  TRIVIAL_NEW_WRAPPERS
 
   MDefinition* foldIfZero(size_t operand) override {
     return getOperand(1 - operand);  // 0 ^ x => x
   }
   MDefinition* foldIfNegOne(size_t operand) override { return this; }
   MDefinition* foldIfEqual() override { return this; }
   MDefinition* foldIfAllBitsSet(size_t operand) override { return this; }
   void computeRange(TempAllocator& alloc) override;
@@ -4593,18 +4597,17 @@ class MShiftInstruction : public MBinary
 };
 
 class MLsh : public MShiftInstruction {
   MLsh(MDefinition* left, MDefinition* right, MIRType type)
       : MShiftInstruction(classOpcode, left, right, type) {}
 
  public:
   INSTRUCTION_HEADER(Lsh)
-  static MLsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                   MIRType type);
+  TRIVIAL_NEW_WRAPPERS
 
   MDefinition* foldIfZero(size_t operand) override {
     // 0 << x => 0
     // x << 0 => x
     return getOperand(0);
   }
 
   void computeRange(TempAllocator& alloc) override;
@@ -4618,18 +4621,17 @@ class MLsh : public MShiftInstruction {
 };
 
 class MRsh : public MShiftInstruction {
   MRsh(MDefinition* left, MDefinition* right, MIRType type)
       : MShiftInstruction(classOpcode, left, right, type) {}
 
  public:
   INSTRUCTION_HEADER(Rsh)
-  static MRsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                   MIRType type);
+  TRIVIAL_NEW_WRAPPERS
 
   MDefinition* foldIfZero(size_t operand) override {
     // 0 >> x => 0
     // x >> 0 => x
     return getOperand(0);
   }
   void computeRange(TempAllocator& alloc) override;
 
@@ -4648,20 +4650,18 @@ class MUrsh : public MShiftInstruction {
   bool bailoutsDisabled_;
 
   MUrsh(MDefinition* left, MDefinition* right, MIRType type)
       : MShiftInstruction(classOpcode, left, right, type),
         bailoutsDisabled_(false) {}
 
  public:
   INSTRUCTION_HEADER(Ursh)
-  static MUrsh* New(TempAllocator& alloc, MDefinition* left,
-                    MDefinition* right);
-  static MUrsh* New(TempAllocator& alloc, MDefinition* left, MDefinition* right,
-                    MIRType type);
+  TRIVIAL_NEW_WRAPPERS
+
   static MUrsh* NewWasm(TempAllocator& alloc, MDefinition* left,
                         MDefinition* right, MIRType type);
 
   MDefinition* foldIfZero(size_t operand) override {
     // 0 >>> x => 0
     if (operand == 0) {
       return getOperand(0);
     }