Bug 1638246 - [MIPS] Add branchTestGCThing, unboxGCThingForGCBarrier and fix branchValueIsNurseryCell. r=jandem
authorZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Fri, 15 May 2020 07:36:40 +0000
changeset 530237 a559275d075cfbe39284476d2281bf6e5bce9b4b
parent 530236 c67a5c3491dfcfdc11dcfd644c26a8d7da67b2c4
child 530238 d711609b40a594536c51543c28ae36e86a8cf8a1
push id37420
push usernerli@mozilla.com
push dateFri, 15 May 2020 21:52:36 +0000
treeherdermozilla-central@f340bbb582d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1638246
milestone78.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 1638246 - [MIPS] Add branchTestGCThing, unboxGCThingForGCBarrier and fix branchValueIsNurseryCell. r=jandem Differential Revision: https://phabricator.services.mozilla.com/D75479
js/src/jit/MacroAssembler.h
js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h
js/src/jit/mips32/MacroAssembler-mips32.h
js/src/jit/mips64/MacroAssembler-mips64.cpp
js/src/jit/mips64/MacroAssembler-mips64.h
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -1565,18 +1565,17 @@ class MacroAssembler : public MacroAssem
                                Label* label)
       DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
 
   inline void branchTestGCThing(Condition cond, const Address& address,
                                 Label* label) PER_SHARED_ARCH;
   inline void branchTestGCThing(Condition cond, const BaseIndex& address,
                                 Label* label) PER_SHARED_ARCH;
   inline void branchTestGCThing(Condition cond, const ValueOperand& value,
-                                Label* label)
-      DEFINED_ON(arm, arm64, x86_shared);
+                                Label* label) PER_SHARED_ARCH;
 
   inline void branchTestPrimitive(Condition cond, const ValueOperand& value,
                                   Label* label)
       DEFINED_ON(arm, arm64, mips32, mips64, x86_shared);
 
   inline void branchTestMagic(Condition cond, const Address& address,
                               Label* label) PER_SHARED_ARCH;
   inline void branchTestMagic(Condition cond, const BaseIndex& address,
@@ -1619,17 +1618,17 @@ class MacroAssembler : public MacroAssem
   inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, L label)
       DEFINED_ON(x86_shared);
 
   void branchPtrInNurseryChunkImpl(Condition cond, Register ptr, Label* label)
       DEFINED_ON(x86);
   template <typename T>
   void branchValueIsNurseryCellImpl(Condition cond, const T& value,
                                     Register temp, Label* label)
-      DEFINED_ON(arm64, x64);
+      DEFINED_ON(arm64, x64, mips64);
 
   template <typename T>
   inline void branchTestUndefinedImpl(Condition cond, const T& t, Label* label)
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T>
   inline void branchTestInt32Impl(Condition cond, const T& t, Label* label)
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T>
@@ -1652,18 +1651,18 @@ class MacroAssembler : public MacroAssem
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T>
   inline void branchTestNullImpl(Condition cond, const T& t, Label* label)
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T>
   inline void branchTestObjectImpl(Condition cond, const T& t, Label* label)
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T>
-  inline void branchTestGCThingImpl(Condition cond, const T& t, Label* label)
-      DEFINED_ON(arm, arm64, x86_shared);
+  inline void branchTestGCThingImpl(Condition cond, const T& t,
+                                    Label* label) PER_SHARED_ARCH;
   template <typename T>
   inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label)
       DEFINED_ON(arm, arm64, x86_shared);
   template <typename T, class L>
   inline void branchTestMagicImpl(Condition cond, const T& t, L label)
       DEFINED_ON(arm, arm64, x86_shared);
 
  public:
--- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h
+++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h
@@ -774,24 +774,33 @@ void MacroAssembler::branchTestObject(Co
                                       Label* label) {
   SecondScratchRegisterScope scratch2(*this);
   Register tag = extractTag(address, scratch2);
   branchTestObject(cond, tag, label);
 }
 
 void MacroAssembler::branchTestGCThing(Condition cond, const Address& address,
                                        Label* label) {
-  MOZ_ASSERT(cond == Equal || cond == NotEqual);
-  SecondScratchRegisterScope scratch2(*this);
-  Register tag = extractTag(address, scratch2);
-  ma_b(tag, ImmTag(JS::detail::ValueLowerInclGCThingTag), label,
-       (cond == Equal) ? AboveOrEqual : Below);
+  branchTestGCThingImpl(cond, address, label);
 }
+
 void MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address,
                                        Label* label) {
+  branchTestGCThingImpl(cond, address, label);
+}
+
+void MacroAssembler::branchTestGCThing(Condition cond,
+                                       const ValueOperand& address,
+                                       Label* label) {
+  branchTestGCThingImpl(cond, address, label);
+}
+
+template <typename T>
+void MacroAssembler::branchTestGCThingImpl(Condition cond, const T& address,
+                                           Label* label) {
   MOZ_ASSERT(cond == Equal || cond == NotEqual);
   SecondScratchRegisterScope scratch2(*this);
   Register tag = extractTag(address, scratch2);
   ma_b(tag, ImmTag(JS::detail::ValueLowerInclGCThingTag), label,
        (cond == Equal) ? AboveOrEqual : Below);
 }
 
 void MacroAssembler::branchTestPrimitive(Condition cond, Register tag,
--- a/js/src/jit/mips32/MacroAssembler-mips32.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32.h
@@ -350,16 +350,19 @@ class MacroAssemblerMIPSCompat : public 
     unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT);
   }
   void unboxObjectOrNull(const Address& src, Register dest);
   void unboxValue(const ValueOperand& src, AnyRegister dest, JSValueType);
 
   void unboxGCThingForGCBarrier(const Address& src, Register dest) {
     unboxObject(src, dest);
   }
+  void unboxGCThingForGCBarrier(const ValueOperand& src, Register dest) {
+    unboxObject(src, dest);
+  }
 
   void notBoolean(const ValueOperand& val) {
     as_xori(val.payloadReg(), val.payloadReg(), 1);
   }
 
   // boxing code
   void boxDouble(FloatRegister src, const ValueOperand& dest, FloatRegister);
   void boxNonDouble(JSValueType type, Register src, const ValueOperand& dest);
--- a/js/src/jit/mips64/MacroAssembler-mips64.cpp
+++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp
@@ -2000,31 +2000,38 @@ void MacroAssembler::moveValue(const Val
 }
 
 // ===============================================================
 // Branch functions
 
 void MacroAssembler::branchValueIsNurseryCell(Condition cond,
                                               const Address& address,
                                               Register temp, Label* label) {
-  MOZ_ASSERT(temp != InvalidReg);
-  loadValue(address, ValueOperand(temp));
-  branchValueIsNurseryCell(cond, ValueOperand(temp), InvalidReg, label);
+  branchValueIsNurseryCellImpl(cond, address, temp, label);
 }
 
 void MacroAssembler::branchValueIsNurseryCell(Condition cond,
                                               ValueOperand value, Register temp,
                                               Label* label) {
+  branchValueIsNurseryCellImpl(cond, value, temp, label);
+}
+
+template <typename T>
+void MacroAssembler::branchValueIsNurseryCellImpl(Condition cond,
+                                                  const T& value, Register temp,
+                                                  Label* label) {
   MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual);
+  // temp may be InvalidReg, use scratch2 instead.
+  SecondScratchRegisterScope scratch2(*this);
 
   Label done;
   branchTestGCThing(Assembler::NotEqual, value,
                     cond == Assembler::Equal ? &done : label);
 
-  unboxGCThingForGCBarrier(value, temp);
+  unboxGCThingForGCBarrier(value, scratch2);
   orPtr(Imm32(gc::ChunkMask), scratch2);
   load32(Address(scratch2, gc::ChunkLocationOffsetFromLastByte), scratch2);
   branch32(cond, scratch2, Imm32(int32_t(gc::ChunkLocation::Nursery)), label);
 
   bind(&done);
 }
 
 void MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs,
--- a/js/src/jit/mips64/MacroAssembler-mips64.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64.h
@@ -378,16 +378,19 @@ class MacroAssemblerMIPS64Compat : publi
                   (uint64_t(0x8) << JSVAL_TAG_SHIFT));
     ma_dins(dest, zero, Imm32(JSVAL_TAG_SHIFT + 3), Imm32(1));
   }
 
   void unboxGCThingForGCBarrier(const Address& src, Register dest) {
     loadPtr(src, dest);
     ma_dext(dest, dest, Imm32(0), Imm32(JSVAL_TAG_SHIFT));
   }
+  void unboxGCThingForGCBarrier(const ValueOperand& src, Register dest) {
+    ma_dext(dest, src.valueReg(), Imm32(0), Imm32(JSVAL_TAG_SHIFT));
+  }
 
   void unboxInt32(const ValueOperand& operand, Register dest);
   void unboxInt32(Register src, Register dest);
   void unboxInt32(const Address& src, Register dest);
   void unboxInt32(const BaseIndex& src, Register dest);
   void unboxBoolean(const ValueOperand& operand, Register dest);
   void unboxBoolean(Register src, Register dest);
   void unboxBoolean(const Address& src, Register dest);