Commit 916af855 authored by André Bargull's avatar André Bargull
Browse files

Bug 1686692 - Part 2: Remove unused MCompare compare types. r=jandem

`Compare_{Boolean, StrictString, Int32MaybeCoerce{Both,LHS,RHS}}` are all no longer used.

Depends on D101869

Differential Revision: https://phabricator.services.mozilla.com/D101871
parent 12d4df24
Loading
Loading
Loading
Loading
+0 −34
Original line number Diff line number Diff line
@@ -754,17 +754,6 @@ void LIRGenerator::visitTest(MTest* test) {
      return;
    }

    // Compare and branch booleans.
    if (comp->compareType() == MCompare::Compare_Boolean) {
      MOZ_ASSERT(left->type() == MIRType::Value);
      MOZ_ASSERT(right->type() == MIRType::Boolean);

      LCompareBAndBranch* lir = new (alloc()) LCompareBAndBranch(
          comp, useBox(left), useRegisterOrConstant(right), ifTrue, ifFalse);
      add(lir, test);
      return;
    }

    // Compare and branch Int32, Symbol or Object pointers.
    if (comp->isInt32Comparison() ||
        comp->compareType() == MCompare::Compare_UInt32 ||
@@ -953,18 +942,6 @@ void LIRGenerator::visitCompare(MCompare* comp) {
    return;
  }

  // Strict compare between value and string
  if (comp->compareType() == MCompare::Compare_StrictString) {
    MOZ_ASSERT(left->type() == MIRType::Value);
    MOZ_ASSERT(right->type() == MIRType::String);

    LCompareStrictS* lir = new (alloc())
        LCompareStrictS(useBox(left), useRegister(right), tempToUnbox());
    define(lir, comp);
    assignSafepoint(lir, comp);
    return;
  }

  // Compare two BigInts.
  if (comp->compareType() == MCompare::Compare_BigInt) {
    auto* lir = new (alloc()) LCompareBigInt(
@@ -1045,17 +1022,6 @@ void LIRGenerator::visitCompare(MCompare* comp) {
    return;
  }

  // Compare booleans.
  if (comp->compareType() == MCompare::Compare_Boolean) {
    MOZ_ASSERT(left->type() == MIRType::Value);
    MOZ_ASSERT(right->type() == MIRType::Boolean);

    LCompareB* lir =
        new (alloc()) LCompareB(useBox(left), useRegisterOrConstant(right));
    define(lir, comp);
    return;
  }

  // Compare Int32, Symbol, Object or Wasm pointers.
  if (comp->isInt32Comparison() ||
      comp->compareType() == MCompare::Compare_UInt32 ||
+9 −43
Original line number Diff line number Diff line
@@ -2957,16 +2957,12 @@ MIRType MCompare::inputType() {
      return MIRType::Null;
    case Compare_UInt32:
    case Compare_Int32:
    case Compare_Int32MaybeCoerceBoth:
    case Compare_Int32MaybeCoerceLHS:
    case Compare_Int32MaybeCoerceRHS:
      return MIRType::Int32;
    case Compare_Double:
      return MIRType::Double;
    case Compare_Float32:
      return MIRType::Float32;
    case Compare_String:
    case Compare_StrictString:
      return MIRType::String;
    case Compare_Symbol:
      return MIRType::Symbol;
@@ -3649,15 +3645,11 @@ bool MCompare::tryFoldEqualOperands(bool* result) {
    return false;
  }

  MOZ_ASSERT(
      compareType_ == Compare_Undefined || compareType_ == Compare_Null ||
      compareType_ == Compare_Boolean || compareType_ == Compare_Int32 ||
      compareType_ == Compare_Int32MaybeCoerceBoth ||
      compareType_ == Compare_Int32MaybeCoerceLHS ||
      compareType_ == Compare_Int32MaybeCoerceRHS ||
  MOZ_ASSERT(compareType_ == Compare_Undefined ||
             compareType_ == Compare_Null || compareType_ == Compare_Int32 ||
             compareType_ == Compare_UInt32 || compareType_ == Compare_Double ||
      compareType_ == Compare_Float32 || compareType_ == Compare_String ||
      compareType_ == Compare_StrictString || compareType_ == Compare_Object ||
             compareType_ == Compare_Float32 ||
             compareType_ == Compare_String || compareType_ == Compare_Object ||
             compareType_ == Compare_Symbol || compareType_ == Compare_BigInt ||
             compareType_ == Compare_BigInt_Int32 ||
             compareType_ == Compare_BigInt_Double ||
@@ -3784,32 +3776,6 @@ bool MCompare::tryFold(bool* result) {
    return false;
  }

  if (compareType_ == Compare_Boolean) {
    MOZ_ASSERT(IsStrictEqualityOp(op));
    MOZ_ASSERT(rhs()->type() == MIRType::Boolean);
    MOZ_ASSERT(lhs()->type() != MIRType::Boolean,
               "Should use Int32 comparison");

    if (!lhs()->mightBeType(MIRType::Boolean)) {
      *result = (op == JSOp::StrictNe);
      return true;
    }
    return false;
  }

  if (compareType_ == Compare_StrictString) {
    MOZ_ASSERT(IsStrictEqualityOp(op));
    MOZ_ASSERT(rhs()->type() == MIRType::String);
    MOZ_ASSERT(lhs()->type() != MIRType::String,
               "Should use String comparison");

    if (!lhs()->mightBeType(MIRType::String)) {
      *result = (op == JSOp::StrictNe);
      return true;
    }
    return false;
  }

  return false;
}

+1 −27
Original line number Diff line number Diff line
@@ -2866,21 +2866,9 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data {
    // Anything compared to Null
    Compare_Null,

    // Undefined compared to Boolean
    // Null      compared to Boolean
    // Double    compared to Boolean
    // String    compared to Boolean
    // Symbol    compared to Boolean
    // Object    compared to Boolean
    // Value     compared to Boolean
    Compare_Boolean,

    // Int32   compared to Int32
    // Boolean compared to Boolean
    Compare_Int32,
    Compare_Int32MaybeCoerceBoth,
    Compare_Int32MaybeCoerceLHS,
    Compare_Int32MaybeCoerceRHS,

    // Int32 compared as unsigneds
    Compare_UInt32,
@@ -2903,15 +2891,6 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data {
    // Symbol compared to Symbol
    Compare_Symbol,

    // Undefined compared to String
    // Null      compared to String
    // Boolean   compared to String
    // Int32     compared to String
    // Double    compared to String
    // Object    compared to String
    // Value     compared to String
    Compare_StrictString,

    // Object compared to Object
    Compare_Object,

@@ -2981,12 +2960,7 @@ class MCompare : public MBinaryInstruction, public ComparePolicy::Data {
                              bool* filtersUndefined, bool* filtersNull);

  CompareType compareType() const { return compareType_; }
  bool isInt32Comparison() const {
    return compareType() == Compare_Int32 ||
           compareType() == Compare_Int32MaybeCoerceBoth ||
           compareType() == Compare_Int32MaybeCoerceLHS ||
           compareType() == Compare_Int32MaybeCoerceRHS;
  }
  bool isInt32Comparison() const { return compareType() == Compare_Int32; }
  bool isDoubleComparison() const { return compareType() == Compare_Double; }
  bool isFloat32Comparison() const { return compareType() == Compare_Float32; }
  bool isNumericComparison() const {
+0 −59
Original line number Diff line number Diff line
@@ -169,58 +169,6 @@ bool ComparePolicy::adjustInputs(TempAllocator& alloc,
    return replace->typePolicy()->adjustInputs(alloc, replace);
  };

  // Compare_Boolean specialization is done for "Anything === Bool"
  // If the LHS is boolean, we set the specialization to Compare_Int32.
  // This matches other comparisons of the form bool === bool and
  // generated code of Compare_Int32 is more efficient.
  if (compare->compareType() == MCompare::Compare_Boolean &&
      def->getOperand(0)->type() == MIRType::Boolean) {
    compare->setCompareType(MCompare::Compare_Int32MaybeCoerceBoth);
  }

  // Compare_Boolean specialization is done for "Anything === Bool"
  // As of previous line Anything can't be Boolean
  if (compare->compareType() == MCompare::Compare_Boolean) {
    // Unbox rhs that is definitely Boolean
    MDefinition* rhs = def->getOperand(1);
    if (rhs->type() != MIRType::Boolean) {
      MInstruction* unbox =
          MUnbox::New(alloc, rhs, MIRType::Boolean, MUnbox::Infallible);
      if (!replaceOperand(1, unbox)) {
        return false;
      }
    }

    MOZ_ASSERT(def->getOperand(0)->type() != MIRType::Boolean);
    MOZ_ASSERT(def->getOperand(1)->type() == MIRType::Boolean);
    return true;
  }

  // Compare_StrictString specialization is done for "Anything === String"
  // If the LHS is string, we set the specialization to Compare_String.
  if (compare->compareType() == MCompare::Compare_StrictString &&
      def->getOperand(0)->type() == MIRType::String) {
    compare->setCompareType(MCompare::Compare_String);
  }

  // Compare_StrictString specialization is done for "Anything === String"
  // As of previous line Anything can't be String
  if (compare->compareType() == MCompare::Compare_StrictString) {
    // Unbox rhs that is definitely String
    MDefinition* rhs = def->getOperand(1);
    if (rhs->type() != MIRType::String) {
      MInstruction* unbox =
          MUnbox::New(alloc, rhs, MIRType::String, MUnbox::Infallible);
      if (!replaceOperand(1, unbox)) {
        return false;
      }
    }

    MOZ_ASSERT(def->getOperand(0)->type() != MIRType::String);
    MOZ_ASSERT(def->getOperand(1)->type() == MIRType::String);
    return true;
  }

  if (compare->compareType() == MCompare::Compare_Undefined ||
      compare->compareType() == MCompare::Compare_Null) {
    // Nothing to do for undefined and null, lowering handles all types.
@@ -298,13 +246,6 @@ bool ComparePolicy::adjustInputs(TempAllocator& alloc,
      }
      case MIRType::Int32: {
        IntConversionInputKind convert = IntConversionInputKind::NumbersOnly;
        if (compare->compareType() == MCompare::Compare_Int32MaybeCoerceBoth ||
            (compare->compareType() == MCompare::Compare_Int32MaybeCoerceLHS &&
             i == 0) ||
            (compare->compareType() == MCompare::Compare_Int32MaybeCoerceRHS &&
             i == 1)) {
          convert = IntConversionInputKind::NumbersOrBoolsOnly;
        }
        replace = MToNumberInt32::New(alloc, in, convert);
        break;
      }