Bug 1391185 - Add missing implementation for MacroAssembler::moveValue to mips32. r=bbouvier
authorDragan Mladjenovic <dragan.mladjenovic@rt-rk.com>
Thu, 17 Aug 2017 01:54:00 -0400
changeset 376009 8ccc616a23b3b1422e9e3b59e64d90544b7b23bc
parent 376008 b3c22267033406033582a84a6076e3b10a232739
child 376010 ce67aec308e0ff38fe223b1a203b481d01223c28
push id32370
push userkwierso@gmail.com
push dateMon, 21 Aug 2017 23:40:30 +0000
treeherdermozilla-central@128a79130ecd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1391185
milestone57.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 1391185 - Add missing implementation for MacroAssembler::moveValue to mips32. r=bbouvier
js/src/jit/mips32/Assembler-mips32.h
js/src/jit/mips32/CodeGenerator-mips32.cpp
js/src/jit/mips32/MacroAssembler-mips32.cpp
--- a/js/src/jit/mips32/Assembler-mips32.h
+++ b/js/src/jit/mips32/Assembler-mips32.h
@@ -68,16 +68,23 @@ static constexpr Register JSReturnReg_Da
 static constexpr Register64 ReturnReg64(InvalidReg, InvalidReg);
 static constexpr FloatRegister ReturnFloat32Reg = { FloatRegisters::f0, FloatRegister::Single };
 static constexpr FloatRegister ReturnDoubleReg = { FloatRegisters::f0, FloatRegister::Double };
 static constexpr FloatRegister ScratchFloat32Reg = { FloatRegisters::f18, FloatRegister::Single };
 static constexpr FloatRegister ScratchDoubleReg = { FloatRegisters::f18, FloatRegister::Double };
 static constexpr FloatRegister SecondScratchFloat32Reg = { FloatRegisters::f16, FloatRegister::Single };
 static constexpr FloatRegister SecondScratchDoubleReg = { FloatRegisters::f16, FloatRegister::Double };
 
+struct ScratchDoubleScope : public AutoFloatRegisterScope
+{
+    explicit ScratchDoubleScope(MacroAssembler& masm)
+      : AutoFloatRegisterScope(masm, ScratchDoubleReg)
+    { }
+};
+
 // Registers used in the GenerateFFIIonExit Disable Activation block.
 // None of these may be the second scratch register (t8).
 static constexpr Register WasmIonExitRegReturnData = JSReturnReg_Data;
 static constexpr Register WasmIonExitRegReturnType = JSReturnReg_Type;
 static constexpr Register WasmIonExitTlsReg = s5;
 
 static constexpr FloatRegister f0  = { FloatRegisters::f0, FloatRegister::Double };
 static constexpr FloatRegister f2  = { FloatRegisters::f2, FloatRegister::Double };
--- a/js/src/jit/mips32/CodeGenerator-mips32.cpp
+++ b/js/src/jit/mips32/CodeGenerator-mips32.cpp
@@ -171,26 +171,20 @@ CodeGeneratorMIPS::visitBox(LBox* box)
     // virtual register. All that needs to be written is the type tag for
     // the type definition.
     masm.move32(Imm32(MIRTypeToTag(box->type())), ToRegister(type));
 }
 
 void
 CodeGeneratorMIPS::visitBoxFloatingPoint(LBoxFloatingPoint* box)
 {
-    const LDefinition* payload = box->getDef(PAYLOAD_INDEX);
-    const LDefinition* type = box->getDef(TYPE_INDEX);
-    const LAllocation* in = box->getOperand(0);
+    const AnyRegister in = ToAnyRegister(box->getOperand(0));
+    const ValueOperand out = ToOutValue(box);
 
-    FloatRegister reg = ToFloatRegister(in);
-    if (box->type() == MIRType::Float32) {
-        masm.convertFloat32ToDouble(reg, ScratchDoubleReg);
-        reg = ScratchDoubleReg;
-    }
-    masm.ma_mv(reg, ValueOperand(ToRegister(type), ToRegister(payload)));
+    masm.moveValue(TypedOrValueRegister(box->type(), in), out);
 }
 
 void
 CodeGeneratorMIPS::visitUnbox(LUnbox* unbox)
 {
     // Note that for unbox, the type and payload indexes are switched on the
     // inputs.
     MUnbox* mir = unbox->mir();
--- a/js/src/jit/mips32/MacroAssembler-mips32.cpp
+++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp
@@ -2254,29 +2254,80 @@ MacroAssembler::callWithABINoProfiler(co
     callWithABIPost(stackAdjust, result);
 }
 // ===============================================================
 // Move instructions
 
 void
 MacroAssembler::moveValue(const TypedOrValueRegister& src, const ValueOperand& dest)
 {
-    MOZ_CRASH("NIY");
+    if (src.hasValue()) {
+        moveValue(src.valueReg(), dest);
+        return;
+    }
+
+    MIRType type = src.type();
+    AnyRegister reg = src.typedReg();
+
+    if (!IsFloatingPointType(type)) {
+        mov(ImmWord(MIRTypeToTag(type)), dest.typeReg());
+        if (reg.gpr() != dest.payloadReg())
+            move32(reg.gpr(), dest.payloadReg());
+        return;
+    }
+
+    ScratchDoubleScope scratch(*this);
+    FloatRegister freg = reg.fpu();
+    if (type == MIRType::Float32) {
+        convertFloat32ToDouble(freg, scratch);
+        freg = scratch;
+    }
+    boxDouble(freg, dest, scratch);
 }
 
 void
 MacroAssembler::moveValue(const ValueOperand& src, const ValueOperand& dest)
 {
-    MOZ_CRASH("NIY");
+    Register s0 = src.typeReg();
+    Register s1 = src.payloadReg();
+    Register d0 = dest.typeReg();
+    Register d1 = dest.payloadReg();
+
+    // Either one or both of the source registers could be the same as a
+    // destination register.
+    if (s1 == d0) {
+        if (s0 == d1) {
+            // If both are, this is just a swap of two registers.
+            ScratchRegisterScope scratch(*this);
+            MOZ_ASSERT(d1 != scratch);
+            MOZ_ASSERT(d0 != scratch);
+            move32(d1, scratch);
+            move32(d0, d1);
+            move32(scratch, d0);
+            return;
+        }
+        // If only one is, copy that source first.
+        mozilla::Swap(s0, s1);
+        mozilla::Swap(d0, d1);
+    }
+
+    if (s0 != d0)
+        move32(s0, d0);
+    if (s1 != d1)
+        move32(s1, d1);
 }
 
 void
 MacroAssembler::moveValue(const Value& src, const ValueOperand& dest)
 {
-    MOZ_CRASH("NIY");
+    move32(Imm32(src.toNunboxTag()), dest.typeReg());
+    if (src.isGCThing())
+        movePtr(ImmGCPtr(src.toGCThing()), dest.payloadReg());
+    else
+        move32(Imm32(src.toNunboxPayload()), dest.payloadReg());
 }
 
 // ===============================================================
 // Branch functions
 
 void
 MacroAssembler::branchValueIsNurseryObject(Condition cond, const Address& address,
                                            Register temp, Label* label)