Fix some minor issues with the handling of ABI arguments (bug 732950, r=pierron)
authorMarty Rosenberg <mrosenberg@mozilla.com>
Tue, 06 Mar 2012 02:05:51 -0800
changeset 112231 0c5009dfea47bbaae3b0cb2e4d74f87def10c266
parent 112230 af7981fd0ca4b5f799e647bf5e8ebd213849be98
child 112232 8979dfc0ddf224ddf4cd4bb43aceaeb7ae78b6fc
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspierron
bugs732950
milestone13.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
Fix some minor issues with the handling of ABI arguments (bug 732950, r=pierron)
js/src/ion/arm/MacroAssembler-arm.cpp
js/src/ion/arm/Trampoline-arm.cpp
--- a/js/src/ion/arm/MacroAssembler-arm.cpp
+++ b/js/src/ion/arm/MacroAssembler-arm.cpp
@@ -2019,16 +2019,18 @@ MacroAssemblerARMCompat::setupAlignedABI
 
 void
 MacroAssemblerARMCompat::setupUnalignedABICall(uint32 args, const Register &scratch)
 {
     setupABICall(args);
     dynamicAlignment_ = true;
 
     ma_mov(sp, scratch);
+
+    // Force sp to be aligned
     ma_and(Imm32(~(StackAlignment - 1)), sp, sp);
     ma_push(scratch);
 }
 
 void
 MacroAssemblerARMCompat::passABIArg(const MoveOperand &from)
 {
     MoveOperand to;
@@ -2046,17 +2048,17 @@ MacroAssemblerARMCompat::passABIArg(cons
 
     Register destReg;
     MoveOperand dest;
     if (GetArgReg(usedSlots_, &destReg)) {
         if (from.isDouble()) {
             floatArgsInGPR[destReg.code() >> 1] = VFPRegister(from.floatReg());
             useResolver = false;
         } else {
-            dest = MoveOperand(dest);
+            dest = MoveOperand(destReg);
         }
     } else {
         uint32 disp = GetArgStackDisp(usedSlots_);
         dest = MoveOperand(sp, disp);
     }
 
     if (useResolver)
         enoughMemory_ = enoughMemory_ && moveResolver_.addMove(from, dest, kind);
@@ -2085,19 +2087,23 @@ void MacroAssemblerARMCompat::checkStack
         bind(&good);
 #endif
 }
 
 void
 MacroAssemblerARMCompat::callWithABI(void *fun, Result result)
 {
     JS_ASSERT(inCall_);
-    uint32 stackAdjust = ((usedSlots_ - 4 > 0) ? usedSlots_ - 4 : 0) * STACK_SLOT_SIZE;
+    uint32 stackAdjust = ((usedSlots_ > NumArgRegs) ? usedSlots_ - NumArgRegs : 0) * STACK_SLOT_SIZE;
     if (!dynamicAlignment_)
-        stackAdjust += 8-(framePushed_ & 7);
+        stackAdjust +=
+            ComputeByteAlignment(framePushed_ + stackAdjust, StackAlignment);
+    else
+        // STACK_SLOT_SIZE account for the saved stack pointer pushed by setupUnalignedABICall
+        stackAdjust += ComputeByteAlignment(stackAdjust + STACK_SLOT_SIZE, StackAlignment);
 
     reserveStack(stackAdjust);
     // Position all arguments.
     {
         enoughMemory_ = enoughMemory_ && moveResolver_.resolve();
         if (!enoughMemory_)
             return;
 
--- a/js/src/ion/arm/Trampoline-arm.cpp
+++ b/js/src/ion/arm/Trampoline-arm.cpp
@@ -604,17 +604,16 @@ IonCompartment::generateVMWrapper(JSCont
 
     // Initialize and set the context parameter.
     // r0 is the first argument register.
     Register cxreg = r0;
     masm.loadJSContext(cx->runtime, cxreg);
     masm.passABIArg(cxreg);
 
     size_t argDisp = 0;
-    size_t argc = 1;
 
     // Copy arguments.
     if (f.explicitArgs) {
         for (uint32 explicitArg = 0; explicitArg < f.explicitArgs; explicitArg++) {
             MoveOperand from;
             switch (f.argProperties(explicitArg)) {
               case VMFunction::WordByValue:
                 masm.passABIArg(MoveOperand(argsBase, argDisp));
@@ -637,17 +636,16 @@ IonCompartment::generateVMWrapper(JSCont
                 break;
             }
         }
     }
 
     // Copy the implicit outparam, if any.
     if (outReg != InvalidReg)
         masm.passABIArg(outReg);
-    JS_ASSERT(f.argc() == argc);
 
     masm.callWithABI(f.wrapped);
 
     // Test for failure.
     Label exception;
     // Called functions return bools, which are 0/false and non-zero/true
     masm.ma_cmp(r0, Imm32(0));
     masm.ma_b(&exception, Assembler::Zero);