Bug 1258327 - Part 6: Remove ToOperand call from mips-shared and mips64 CodeGenerator. r=hev
authorTooru Fujisawa <arai_a@mac.com>
Sat, 26 Mar 2016 09:40:23 +0900
changeset 290539 bca4017b118375f338ceadc8ce3839bce0f9bec0
parent 290538 c73a466ab48c0ad8364bcc8a90a57caeae3c66ad
child 290540 3dcf36d71a610ea6f483f73750cf77702eefdd52
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershev
bugs1258327
milestone48.0a1
Bug 1258327 - Part 6: Remove ToOperand call from mips-shared and mips64 CodeGenerator. r=hev
js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
js/src/jit/mips64/CodeGenerator-mips64.cpp
js/src/jit/mips64/MacroAssembler-mips64.cpp
js/src/jit/mips64/MacroAssembler-mips64.h
--- a/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
+++ b/js/src/jit/mips-shared/CodeGenerator-mips-shared.cpp
@@ -1905,44 +1905,43 @@ CodeGeneratorMIPSShared::visitAsmJSPassS
 }
 
 void
 CodeGeneratorMIPSShared::visitAsmSelect(LAsmSelect* ins)
 {
     MIRType mirType = ins->mir()->type();
 
     Register cond = ToRegister(ins->condExpr());
+    const LAllocation* falseExpr = ins->falseExpr();
 
     if (mirType == MIRType_Int32) {
-        Register falseExpr = ToRegister(ins->falseExpr());
         Register out = ToRegister(ins->output());
         MOZ_ASSERT(ToRegister(ins->trueExpr()) == out, "true expr input is reused for output");
-        masm.as_movz(out, falseExpr, cond);
+        masm.as_movz(out, ToRegister(falseExpr), cond);
         return;
     }
 
-    Operand falseExpr = ToOperand(ins->falseExpr());
     FloatRegister out = ToFloatRegister(ins->output());
     MOZ_ASSERT(ToFloatRegister(ins->trueExpr()) == out, "true expr input is reused for output");
 
-    if (falseExpr.getTag() == Operand::FREG) {
+    if (falseExpr->isFloatReg()) {
         if (mirType == MIRType_Float32)
-            masm.as_movz(Assembler::SingleFloat, out, falseExpr.toFReg(), cond);
+            masm.as_movz(Assembler::SingleFloat, out, ToFloatRegister(falseExpr), cond);
         else if (mirType == MIRType_Double)
-            masm.as_movz(Assembler::DoubleFloat, out, falseExpr.toFReg(), cond);
+            masm.as_movz(Assembler::DoubleFloat, out, ToFloatRegister(falseExpr), cond);
         else
             MOZ_CRASH("unhandled type in visitAsmSelect!");
     } else {
         Label done;
         masm.ma_b(cond, cond, &done, Assembler::NonZero, ShortJump);
 
         if (mirType == MIRType_Float32)
-            masm.loadFloat32(falseExpr.toAddress(), out);
+            masm.loadFloat32(ToAddress(falseExpr), out);
         else if (mirType == MIRType_Double)
-            masm.loadDouble(falseExpr.toAddress(), out);
+            masm.loadDouble(ToAddress(falseExpr), out);
         else
             MOZ_CRASH("unhandled type in visitAsmSelect!");
 
         masm.bind(&done);
     }
 }
 
 void
--- a/js/src/jit/mips64/CodeGenerator-mips64.cpp
+++ b/js/src/jit/mips64/CodeGenerator-mips64.cpp
@@ -172,33 +172,58 @@ CodeGeneratorMIPS64::visitUnbox(LUnbox* 
 
     if (mir->fallible()) {
         const ValueOperand value = ToValue(unbox, LUnbox::Input);
         masm.splitTag(value, SecondScratchReg);
         bailoutCmp32(Assembler::NotEqual, SecondScratchReg, Imm32(MIRTypeToTag(mir->type())),
                      unbox->snapshot());
     }
 
-    Operand input = ToOperand(unbox->getOperand(LUnbox::Input));
+    LAllocation* input = unbox->getOperand(LUnbox::Input);
     Register result = ToRegister(unbox->output());
+    if (input->isRegister()) {
+        Register inputReg = ToRegister(input);
+        switch (mir->type()) {
+          case MIRType_Int32:
+            masm.unboxInt32(inputReg, result);
+            break;
+          case MIRType_Boolean:
+            masm.unboxBoolean(inputReg, result);
+            break;
+          case MIRType_Object:
+            masm.unboxObject(inputReg, result);
+            break;
+          case MIRType_String:
+            masm.unboxString(inputReg, result);
+            break;
+          case MIRType_Symbol:
+            masm.unboxSymbol(inputReg, result);
+            break;
+          default:
+            MOZ_CRASH("Given MIRType cannot be unboxed.");
+        }
+        return;
+    }
+
+    Address inputAddr = ToAddress(input);
     switch (mir->type()) {
       case MIRType_Int32:
-        masm.unboxInt32(input, result);
+        masm.unboxInt32(inputAddr, result);
         break;
       case MIRType_Boolean:
-        masm.unboxBoolean(input, result);
+        masm.unboxBoolean(inputAddr, result);
         break;
       case MIRType_Object:
-        masm.unboxObject(input, result);
+        masm.unboxObject(inputAddr, result);
         break;
       case MIRType_String:
-        masm.unboxString(input, result);
+        masm.unboxString(inputAddr, result);
         break;
       case MIRType_Symbol:
-        masm.unboxSymbol(input, result);
+        masm.unboxSymbol(inputAddr, result);
         break;
       default:
         MOZ_CRASH("Given MIRType cannot be unboxed.");
     }
 }
 
 Register
 CodeGeneratorMIPS64::splitTagForTest(const ValueOperand& value)
@@ -279,27 +304,27 @@ CodeGeneratorMIPS64::visitCompareBitwise
 }
 
 void
 CodeGeneratorMIPS64::visitAsmSelectI64(LAsmSelectI64* lir)
 {
     MOZ_ASSERT(lir->mir()->type() == MIRType_Int64);
 
     Register cond = ToRegister(lir->condExpr());
-    Operand falseExpr = ToOperand(lir->falseExpr());
+    const LAllocation* falseExpr = lir->falseExpr();
 
     Register out = ToRegister(lir->output());
     MOZ_ASSERT(ToRegister(lir->trueExpr()) == out, "true expr is reused for input");
 
-    if (falseExpr.getTag() == Operand::REG) {
-        masm.as_movz(out, falseExpr.toReg(), cond);
+    if (falseExpr->isRegister()) {
+        masm.as_movz(out, ToRegister(falseExpr), cond);
     } else {
         Label done;
         masm.ma_b(cond, cond, &done, Assembler::NonZero, ShortJump);
-        masm.loadPtr(falseExpr.toAddress(), out);
+        masm.loadPtr(ToAddress(falseExpr), out);
         masm.bind(&done);
     }
 }
 
 void
 CodeGeneratorMIPS64::setReturnDoubleRegs(LiveRegisterSet* regs)
 {
     MOZ_ASSERT(ReturnFloat32Reg.reg_ == FloatRegisters::f0);
--- a/js/src/jit/mips64/MacroAssembler-mips64.cpp
+++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp
@@ -1271,31 +1271,20 @@ MacroAssemblerMIPS64Compat::unboxNonDoub
 void
 MacroAssemblerMIPS64Compat::unboxInt32(const ValueOperand& operand, Register dest)
 {
     ma_dsll(dest, operand.valueReg(), Imm32(32));
     ma_dsra(dest, dest, Imm32(32));
 }
 
 void
-MacroAssemblerMIPS64Compat::unboxInt32(const Operand& operand, Register dest)
+MacroAssemblerMIPS64Compat::unboxInt32(Register src, Register dest)
 {
-    switch(operand.getTag()) {
-    case Operand::REG:
-        ma_dsll(dest, operand.toReg(), Imm32(32));
-        ma_dsra(dest, dest, Imm32(32));
-        break;
-    case Operand::MEM:
-        unboxInt32(operand.toAddress(), dest);
-        break;
-    case Operand::FREG:
-    default:
-        MOZ_CRASH("unexpected operand kind");
-        break;
-    }
+    ma_dsll(dest, src, Imm32(32));
+    ma_dsra(dest, dest, Imm32(32));
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxInt32(const Address& src, Register dest)
 {
     load32(Address(src.base, src.offset), dest);
 }
 
@@ -1308,30 +1297,19 @@ MacroAssemblerMIPS64Compat::unboxInt32(c
 
 void
 MacroAssemblerMIPS64Compat::unboxBoolean(const ValueOperand& operand, Register dest)
 {
     ma_dext(dest, operand.valueReg(), Imm32(0), Imm32(32));
 }
 
 void
-MacroAssemblerMIPS64Compat::unboxBoolean(const Operand& operand, Register dest)
+MacroAssemblerMIPS64Compat::unboxBoolean(Register src, Register dest)
 {
-    switch(operand.getTag()) {
-    case Operand::REG:
-        ma_dext(dest, operand.toReg(), Imm32(0), Imm32(32));
-        break;
-    case Operand::MEM:
-        unboxBoolean(operand.toAddress(), dest);
-        break;
-    case Operand::FREG:
-    default:
-        MOZ_CRASH("unexpected operand kind");
-        break;
-    }
+    ma_dext(dest, src, Imm32(0), Imm32(32));
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxBoolean(const Address& src, Register dest)
 {
     ma_load(dest, Address(src.base, src.offset), SizeWord, ZeroExtend);
 }
 
@@ -1356,82 +1334,49 @@ MacroAssemblerMIPS64Compat::unboxDouble(
 
 void
 MacroAssemblerMIPS64Compat::unboxString(const ValueOperand& operand, Register dest)
 {
     unboxNonDouble(operand, dest);
 }
 
 void
-MacroAssemblerMIPS64Compat::unboxString(const Operand& operand, Register dest)
+MacroAssemblerMIPS64Compat::unboxString(Register src, Register dest)
 {
-    switch(operand.getTag()) {
-    case Operand::REG:
-        ma_dext(dest, operand.toReg(), Imm32(0), Imm32(JSVAL_TAG_SHIFT));
-        break;
-    case Operand::MEM:
-        unboxNonDouble(operand.toAddress(), dest);
-        break;
-    case Operand::FREG:
-    default:
-        MOZ_CRASH("unexpected operand kind");
-        break;
-    }
+    ma_dext(dest, src, Imm32(0), Imm32(JSVAL_TAG_SHIFT));
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxString(const Address& src, Register dest)
 {
     unboxNonDouble(src, dest);
 }
 
 void
-MacroAssemblerMIPS64Compat::unboxSymbol(const Operand& operand, Register dest)
+MacroAssemblerMIPS64Compat::unboxSymbol(Register src, Register dest)
 {
-    switch(operand.getTag()) {
-    case Operand::REG:
-        ma_dext(dest, operand.toReg(), Imm32(0), Imm32(JSVAL_TAG_SHIFT));
-        break;
-    case Operand::MEM:
-        unboxNonDouble(operand.toAddress(), dest);
-        break;
-    case Operand::FREG:
-    default:
-        MOZ_CRASH("unexpected operand kind");
-        break;
-    }
+    ma_dext(dest, src, Imm32(0), Imm32(JSVAL_TAG_SHIFT));
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxSymbol(const Address& src, Register dest)
 {
     unboxNonDouble(src, dest);
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxObject(const ValueOperand& src, Register dest)
 {
     unboxNonDouble(src, dest);
 }
 
 void
-MacroAssemblerMIPS64Compat::unboxObject(const Operand& src, Register dest)
+MacroAssemblerMIPS64Compat::unboxObject(Register src, Register dest)
 {
-    switch(src.getTag()) {
-    case Operand::REG:
-        ma_dext(dest, src.toReg(), Imm32(0), Imm32(JSVAL_TAG_SHIFT));
-        break;
-    case Operand::MEM:
-        unboxNonDouble(src.toAddress(), dest);
-        break;
-    case Operand::FREG:
-    default:
-        MOZ_CRASH("unexpected operand kind");
-        break;
-    }
+    ma_dext(dest, src, Imm32(0), Imm32(JSVAL_TAG_SHIFT));
 }
 
 void
 MacroAssemblerMIPS64Compat::unboxObject(const Address& src, Register dest)
 {
     unboxNonDouble(src, dest);
 }
 
--- a/js/src/jit/mips64/MacroAssembler-mips64.h
+++ b/js/src/jit/mips64/MacroAssembler-mips64.h
@@ -336,33 +336,34 @@ class MacroAssemblerMIPS64Compat : publi
         return SecondScratchReg;
     }
 
     // unboxing code
     void unboxNonDouble(const ValueOperand& operand, Register dest);
     void unboxNonDouble(const Address& src, Register dest);
     void unboxNonDouble(const BaseIndex& src, Register dest);
     void unboxInt32(const ValueOperand& operand, Register dest);
-    void unboxInt32(const Operand& 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(const Operand& operand, Register dest);
+    void unboxBoolean(Register src, Register dest);
     void unboxBoolean(const Address& src, Register dest);
     void unboxBoolean(const BaseIndex& src, Register dest);
     void unboxDouble(const ValueOperand& operand, FloatRegister dest);
+    void unboxDouble(Register src, Register dest);
     void unboxDouble(const Address& src, FloatRegister dest);
     void unboxString(const ValueOperand& operand, Register dest);
-    void unboxString(const Operand& operand, Register dest);
+    void unboxString(Register src, Register dest);
     void unboxString(const Address& src, Register dest);
     void unboxSymbol(const ValueOperand& src, Register dest);
-    void unboxSymbol(const Operand& src, Register dest);
+    void unboxSymbol(Register src, Register dest);
     void unboxSymbol(const Address& src, Register dest);
     void unboxObject(const ValueOperand& src, Register dest);
-    void unboxObject(const Operand& src, Register dest);
+    void unboxObject(Register src, Register dest);
     void unboxObject(const Address& src, Register dest);
     void unboxObject(const BaseIndex& src, Register dest) { unboxNonDouble(src, dest); }
     void unboxValue(const ValueOperand& src, AnyRegister dest);
     void unboxPrivate(const ValueOperand& src, Register dest);
 
     void notBoolean(const ValueOperand& val) {
         as_xori(val.valueReg(), val.valueReg(), 1);
     }