Bug 917991 - IonMonkey: Various x86 MoveEmitter cleanups. r=jandem
authorDan Gohman <sunfish@google.com>
Tue, 24 Sep 2013 20:08:57 -0700
changeset 148626 1ddce77f2e7eda91d1f983fc1babeab8deb37296
parent 148625 230cc5fecdef089c3e349010b164dbeeea1321e6
child 148627 faef127548801a5c102fe0a4807361b50af1d4fa
push id25349
push userryanvm@gmail.com
push dateWed, 25 Sep 2013 18:52:12 +0000
treeherdermozilla-central@39f30376058c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs917991
milestone27.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 917991 - IonMonkey: Various x86 MoveEmitter cleanups. r=jandem
js/src/jit/shared/MoveEmitter-x86-shared.cpp
js/src/jit/shared/MoveEmitter-x86-shared.h
--- a/js/src/jit/shared/MoveEmitter-x86-shared.cpp
+++ b/js/src/jit/shared/MoveEmitter-x86-shared.cpp
@@ -135,43 +135,48 @@ MoveEmitterX86::emit(const MoveResolver 
     }
 }
 
 MoveEmitterX86::~MoveEmitterX86()
 {
     assertDone();
 }
 
-Operand
+Address
 MoveEmitterX86::cycleSlot()
 {
     if (pushedAtCycle_ == -1) {
         // Reserve stack for cycle resolution
         masm.reserveStack(sizeof(double));
         pushedAtCycle_ = masm.framePushed();
     }
 
-    return Operand(StackPointer, masm.framePushed() - pushedAtCycle_);
+    return Address(StackPointer, masm.framePushed() - pushedAtCycle_);
+}
+
+Address
+MoveEmitterX86::toAddress(const MoveOperand &operand) const
+{
+    if (operand.base() != StackPointer)
+        return Address(operand.base(), operand.disp());
+
+    JS_ASSERT(operand.disp() >= 0);
+
+    // Otherwise, the stack offset may need to be adjusted.
+    return Address(StackPointer, operand.disp() + (masm.framePushed() - pushedAtStart_));
 }
 
 // Warning, do not use the resulting operand with pop instructions, since they
 // compute the effective destination address after altering the stack pointer.
 // Use toPopOperand if an Operand is needed for a pop.
 Operand
 MoveEmitterX86::toOperand(const MoveOperand &operand) const
 {
-    if (operand.isMemory() || operand.isEffectiveAddress() || operand.isFloatAddress()) {
-        if (operand.base() != StackPointer)
-            return Operand(operand.base(), operand.disp());
-
-        JS_ASSERT(operand.disp() >= 0);
-
-        // Otherwise, the stack offset may need to be adjusted.
-        return Operand(StackPointer, operand.disp() + (masm.framePushed() - pushedAtStart_));
-    }
+    if (operand.isMemory() || operand.isEffectiveAddress() || operand.isFloatAddress())
+        return Operand(toAddress(operand));
     if (operand.isGeneralReg())
         return Operand(operand.reg());
 
     JS_ASSERT(operand.isFloatReg());
     return Operand(operand.floatReg());
 }
 
 // This is the same as toOperand except that it computes an Operand suitable for
@@ -204,42 +209,39 @@ MoveEmitterX86::breakCycle(const MoveOpe
     // There is some pattern:
     //   (A -> B)
     //   (B -> A)
     //
     // This case handles (A -> B), which we reach first. We save B, then allow
     // the original move to continue.
     if (kind == Move::DOUBLE) {
         if (to.isMemory()) {
-            masm.loadDouble(toOperand(to), ScratchFloatReg);
+            masm.loadDouble(toAddress(to), ScratchFloatReg);
             masm.storeDouble(ScratchFloatReg, cycleSlot());
         } else {
             masm.storeDouble(to.floatReg(), cycleSlot());
         }
     } else {
-        if (to.isMemory())
-            masm.Push(toOperand(to));
-        else
-            masm.Push(to.reg());
+        masm.Push(toOperand(to));
     }
 }
 
 void
 MoveEmitterX86::completeCycle(const MoveOperand &to, Move::Kind kind)
 {
     // There is some pattern:
     //   (A -> B)
     //   (B -> A)
     //
     // This case handles (B -> A), which we reach last. We emit a move from the
     // saved value of B, to A.
     if (kind == Move::DOUBLE) {
         if (to.isMemory()) {
             masm.loadDouble(cycleSlot(), ScratchFloatReg);
-            masm.storeDouble(ScratchFloatReg, toOperand(to));
+            masm.storeDouble(ScratchFloatReg, toAddress(to));
         } else {
             masm.loadDouble(cycleSlot(), to.floatReg());
         }
     } else {
         if (to.isMemory()) {
             masm.Pop(toPopOperand(to));
         } else {
             masm.Pop(to.reg());
@@ -250,24 +252,24 @@ MoveEmitterX86::completeCycle(const Move
 void
 MoveEmitterX86::emitGeneralMove(const MoveOperand &from, const MoveOperand &to)
 {
     if (from.isGeneralReg()) {
         masm.mov(from.reg(), toOperand(to));
     } else if (to.isGeneralReg()) {
         JS_ASSERT(from.isMemory() || from.isEffectiveAddress());
         if (from.isMemory())
-            masm.mov(toOperand(from), to.reg());
+            masm.loadPtr(toAddress(from), to.reg());
         else
             masm.lea(toOperand(from), to.reg());
     } else if (from.isMemory()) {
         // Memory to memory gpr move.
 #ifdef JS_CPU_X64
         // x64 has a ScratchReg. Use it.
-        masm.mov(toOperand(from), ScratchReg);
+        masm.loadPtr(toAddress(from), ScratchReg);
         masm.mov(ScratchReg, toOperand(to));
 #else
         // No ScratchReg; bounce it off the stack.
         masm.Push(toOperand(from));
         masm.Pop(toPopOperand(to));
 #endif
     } else {
         // Effective address to memory move.
@@ -287,22 +289,22 @@ MoveEmitterX86::emitGeneralMove(const Mo
 }
 
 void
 MoveEmitterX86::emitDoubleMove(const MoveOperand &from, const MoveOperand &to)
 {
     if (from.isFloatReg()) {
         masm.movsd(from.floatReg(), toOperand(to));
     } else if (to.isFloatReg()) {
-        masm.loadDouble(toOperand(from), to.floatReg());
+        masm.loadDouble(toAddress(from), to.floatReg());
     } else {
         // Memory to memory float move.
         JS_ASSERT(from.isMemory());
-        masm.loadDouble(toOperand(from), ScratchFloatReg);
-        masm.storeDouble(ScratchFloatReg, toOperand(to));
+        masm.loadDouble(toAddress(from), ScratchFloatReg);
+        masm.storeDouble(ScratchFloatReg, toAddress(to));
     }
 }
 
 void
 MoveEmitterX86::assertDone()
 {
     JS_ASSERT(!inCycle_);
 }
--- a/js/src/jit/shared/MoveEmitter-x86-shared.h
+++ b/js/src/jit/shared/MoveEmitter-x86-shared.h
@@ -26,17 +26,18 @@ class MoveEmitterX86
     // Original stack push value.
     uint32_t pushedAtStart_;
 
     // This is a store stack offset for the cycle-break spill slot, snapshotting
     // codegen->framePushed_ at the time it is allocated. -1 if not allocated.
     int32_t pushedAtCycle_;
 
     void assertDone();
-    Operand cycleSlot();
+    Address cycleSlot();
+    Address toAddress(const MoveOperand &operand) const;
     Operand toOperand(const MoveOperand &operand) const;
     Operand toPopOperand(const MoveOperand &operand) const;
 
     size_t characterizeCycle(const MoveResolver &moves, size_t i,
                              bool *allGeneralRegs, bool *allFloatRegs);
     bool maybeEmitOptimizedCycle(const MoveResolver &moves, size_t i,
                                  bool allGeneralRegs, bool allFloatRegs, size_t swapCount);
     void emitGeneralMove(const MoveOperand &from, const MoveOperand &to);