From 497cb2e84ebc88aa65d5fe877d1e7597ce50c262 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 28 Dec 2012 12:40:45 -0800 Subject: [PATCH] Bug 817943 part 2. Make the x86-64 and ARM versions of passABIArg not generate no-op moves and add asserts to the moveResolver that there are no such moves. r=pierron,mjrosenberg --- js/src/ion/MoveResolver.cpp | 2 ++ js/src/ion/arm/MacroAssembler-arm.cpp | 14 ++++++++++---- js/src/ion/x64/MacroAssembler-x64.cpp | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/js/src/ion/MoveResolver.cpp b/js/src/ion/MoveResolver.cpp index 9fe067d0701..01fb6e3384e 100644 --- a/js/src/ion/MoveResolver.cpp +++ b/js/src/ion/MoveResolver.cpp @@ -24,6 +24,8 @@ MoveResolver::resetState() bool MoveResolver::addMove(const MoveOperand &from, const MoveOperand &to, Move::Kind kind) { + // Assert that we're not doing no-op moves. + JS_ASSERT(!(from == to)); PendingMove *pm = movePool_.allocate(); if (!pm) return false; diff --git a/js/src/ion/arm/MacroAssembler-arm.cpp b/js/src/ion/arm/MacroAssembler-arm.cpp index 94de77cbb4f..ca4ed6e5d7d 100644 --- a/js/src/ion/arm/MacroAssembler-arm.cpp +++ b/js/src/ion/arm/MacroAssembler-arm.cpp @@ -2708,10 +2708,13 @@ MacroAssemblerARMCompat::passABIArg(const MoveOperand &from) if (from.isDouble()) { FloatRegister fr; if (GetFloatArgReg(usedIntSlots_, usedFloatSlots_, &fr)) { - enoughMemory_ = moveResolver_.addMove(from, MoveOperand(fr), Move::DOUBLE); + if (!from.isFloatReg() || from.floatReg() != fr) { + enoughMemory_ = moveResolver_.addMove(from, MoveOperand(fr), Move::DOUBLE); + } + // else nothing to do; the value is in the right register already } else { // If (and only if) the integer registers have started spilling, do we - // need to take the double register's alignment into accoun + // need to take the double register's alignment into account uint32_t disp = GetFloatArgStackDisp(usedIntSlots_, usedFloatSlots_, &padding_); enoughMemory_ = moveResolver_.addMove(from, MoveOperand(sp, disp), Move::DOUBLE); } @@ -2719,13 +2722,16 @@ MacroAssemblerARMCompat::passABIArg(const MoveOperand &from) } else { Register r; if (GetIntArgReg(usedIntSlots_, usedFloatSlots_, &r)) { - enoughMemory_ = moveResolver_.addMove(from, MoveOperand(r), Move::GENERAL); + if (!from.isGeneralReg() || from.reg() != r) { + enoughMemory_ = moveResolver_.addMove(from, MoveOperand(r), Move::GENERAL); + } + // else nothing to do; the value is in the right register already } else { uint32_t disp = GetIntArgStackDisp(usedIntSlots_, usedFloatSlots_, &padding_); fprintf(stderr, "Float on the stack! (%d)\n", disp); enoughMemory_ = moveResolver_.addMove(from, MoveOperand(sp, disp), Move::GENERAL); } - usedIntSlots_++; + usedIntSlots_++; } } diff --git a/js/src/ion/x64/MacroAssembler-x64.cpp b/js/src/ion/x64/MacroAssembler-x64.cpp index 36b6b76aa7f..2000dcfa94b 100644 --- a/js/src/ion/x64/MacroAssembler-x64.cpp +++ b/js/src/ion/x64/MacroAssembler-x64.cpp @@ -51,6 +51,10 @@ MacroAssemblerX64::passABIArg(const MoveOperand &from) if (from.isDouble()) { FloatRegister dest; if (GetFloatArgReg(passedIntArgs_, passedFloatArgs_++, &dest)) { + if (from.isFloatReg() && from.floatReg() == dest) { + // Nothing to do; the value is in the right register already + return; + } to = MoveOperand(dest); } else { to = MoveOperand(StackPointer, stackForCall_); @@ -60,6 +64,10 @@ MacroAssemblerX64::passABIArg(const MoveOperand &from) } else { Register dest; if (GetIntArgReg(passedIntArgs_++, passedFloatArgs_, &dest)) { + if (from.isGeneralReg() && from.reg() == dest) { + // Nothing to do; the value is in the right register already + return; + } to = MoveOperand(dest); } else { to = MoveOperand(StackPointer, stackForCall_);