Bug 1286816 - InvertCondition(DoubleCondition). r=h4writer
authorLars T Hansen <lhansen@mozilla.com>
Thu, 24 Nov 2016 09:17:45 +0100
changeset 324426 119af218c29ab502f82d60b4340bdb5f734bf6fd
parent 324425 b023c7d0e8b2e00960b134793dc71fd25b74dc3d
child 324427 3c9d3d8df078b513149aa0228621dad461abe94d
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersh4writer
bugs1286816
milestone53.0a1
Bug 1286816 - InvertCondition(DoubleCondition). r=h4writer
js/src/jit/arm/Assembler-arm.cpp
js/src/jit/arm/Assembler-arm.h
js/src/jit/arm64/vixl/Assembler-vixl.h
js/src/jit/x86-shared/Assembler-x86-shared.cpp
js/src/jit/x86-shared/Assembler-x86-shared.h
--- a/js/src/jit/arm/Assembler-arm.cpp
+++ b/js/src/jit/arm/Assembler-arm.cpp
@@ -1005,16 +1005,24 @@ Assembler::ConditionWithoutEqual(Conditi
         return GreaterThan;
       case Above:
       case AboveOrEqual:
         return Above;
       default:
         MOZ_CRASH("unexpected condition");
     }
 }
+
+Assembler::DoubleCondition
+Assembler::InvertCondition(DoubleCondition cond)
+{
+    const uint32_t ConditionInversionBit = 0x10000000;
+    return DoubleCondition(ConditionInversionBit ^ cond);
+}
+
 Imm8::TwoImm8mData
 Imm8::EncodeTwoImms(uint32_t imm)
 {
     // In the ideal case, we are looking for a number that (in binary) looks
     // like:
     //   0b((00)*)n_1((00)*)n_2((00)*)
     //      left  n1   mid  n2
     //   where both n_1 and n_2 fit into 8 bits.
--- a/js/src/jit/arm/Assembler-arm.h
+++ b/js/src/jit/arm/Assembler-arm.h
@@ -1343,16 +1343,18 @@ class Assembler : public AssemblerShared
     void initWithAllocator() {
         m_buffer.initWithAllocator();
     }
 
     static Condition InvertCondition(Condition cond);
     static Condition UnsignedCondition(Condition cond);
     static Condition ConditionWithoutEqual(Condition cond);
 
+    static DoubleCondition InvertCondition(DoubleCondition cond);
+
     // MacroAssemblers hold onto gcthings, so they are traced by the GC.
     void trace(JSTracer* trc);
     void writeRelocation(BufferOffset src) {
         jumpRelocations_.writeUnsigned(src.getOffset());
     }
 
     // As opposed to x86/x64 version, the data relocation has to be executed
     // before to recover the pointer, and not after.
--- a/js/src/jit/arm64/vixl/Assembler-vixl.h
+++ b/js/src/jit/arm64/vixl/Assembler-vixl.h
@@ -936,16 +936,20 @@ class Assembler : public MozBaseAssemble
     case pl:
       return mi;
     default:
       MOZ_CRASH("TODO: figure this case out.");
     }
     return static_cast<Condition>(cond ^ 1);
   }
 
+  static inline DoubleCondition InvertCondition(DoubleCondition cond) {
+    MOZ_CRASH("Not yet implemented: InvertCondition(DoubleCondition)");
+  }
+
   static inline Condition ConditionFromDoubleCondition(DoubleCondition cond) {
     VIXL_ASSERT(!(cond & DoubleConditionBitSpecial));
     return static_cast<Condition>(cond);
   }
 
   // Instruction set functions.
 
   // Branch / Jump instructions.
--- a/js/src/jit/x86-shared/Assembler-x86-shared.cpp
+++ b/js/src/jit/x86-shared/Assembler-x86-shared.cpp
@@ -216,16 +216,49 @@ AssemblerX86Shared::ConditionWithoutEqua
       case Above:
       case AboveOrEqual:
         return Above;
       default:
         MOZ_CRASH("unexpected condition");
     }
 }
 
+AssemblerX86Shared::DoubleCondition
+AssemblerX86Shared::InvertCondition(DoubleCondition cond)
+{
+    switch (cond) {
+      case DoubleEqual:
+        return DoubleNotEqualOrUnordered;
+      case DoubleEqualOrUnordered:
+        return DoubleNotEqual;
+      case DoubleNotEqualOrUnordered:
+        return DoubleEqual;
+      case DoubleNotEqual:
+        return DoubleEqualOrUnordered;
+      case DoubleLessThan:
+        return DoubleGreaterThanOrEqualOrUnordered;
+      case DoubleLessThanOrUnordered:
+        return DoubleGreaterThanOrEqual;
+      case DoubleLessThanOrEqual:
+        return DoubleGreaterThanOrUnordered;
+      case DoubleLessThanOrEqualOrUnordered:
+        return DoubleGreaterThan;
+      case DoubleGreaterThan:
+        return DoubleLessThanOrEqualOrUnordered;
+      case DoubleGreaterThanOrUnordered:
+        return DoubleLessThanOrEqual;
+      case DoubleGreaterThanOrEqual:
+        return DoubleLessThanOrUnordered;
+      case DoubleGreaterThanOrEqualOrUnordered:
+        return DoubleLessThan;
+      default:
+        MOZ_CRASH("unexpected condition");
+    }
+}
+
 void
 AssemblerX86Shared::verifyHeapAccessDisassembly(uint32_t begin, uint32_t end,
                                                 const Disassembler::HeapAccess& heapAccess)
 {
 #ifdef DEBUG
     if (masm.oom())
         return;
     Disassembler::VerifyHeapAccess(masm.data() + begin, masm.data() + end, heapAccess);
--- a/js/src/jit/x86-shared/Assembler-x86-shared.h
+++ b/js/src/jit/x86-shared/Assembler-x86-shared.h
@@ -382,16 +382,18 @@ class AssemblerX86Shared : public Assemb
         JS_STATIC_ASSERT(!((Equal | NotEqual | Above | AboveOrEqual | Below |
                             BelowOrEqual | Parity | NoParity) & DoubleConditionBits));
     }
 
     static Condition InvertCondition(Condition cond);
     static Condition UnsignedCondition(Condition cond);
     static Condition ConditionWithoutEqual(Condition cond);
 
+    static DoubleCondition InvertCondition(DoubleCondition cond);
+
     // Return the primary condition to test. Some primary conditions may not
     // handle NaNs properly and may therefore require a secondary condition.
     // Use NaNCondFromDoubleCondition to determine what else is needed.
     static inline Condition ConditionFromDoubleCondition(DoubleCondition cond) {
         return static_cast<Condition>(cond & ~DoubleConditionBits);
     }
 
     static void TraceDataRelocations(JSTracer* trc, JitCode* code, CompactBufferReader& reader);