diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index 716418b802f..a0e45c4e103 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -3876,7 +3876,7 @@ MacroAssemblerARMCompat::callWithABIPre(uint32_t *stackAdjust, bool callFromAsmJ if (useHardFpABI()) *stackAdjust += 2*((usedFloatSlots_ > NumFloatArgRegs) ? usedFloatSlots_ - NumFloatArgRegs : 0) * sizeof(intptr_t); #endif - uint32_t alignmentAtPrologue = (callFromAsmJS) ? AlignmentAtAsmJSPrologue : 0; + uint32_t alignmentAtPrologue = callFromAsmJS ? AlignmentAtAsmJSPrologue : 0; if (!dynamicAlignment_) { *stackAdjust += ComputeByteAlignment(framePushed_ + *stackAdjust + alignmentAtPrologue, diff --git a/js/src/jit/mips/Assembler-mips.h b/js/src/jit/mips/Assembler-mips.h index 7754a4cd7d3..33910ad42e7 100644 --- a/js/src/jit/mips/Assembler-mips.h +++ b/js/src/jit/mips/Assembler-mips.h @@ -153,8 +153,7 @@ static const uint32_t CodeAlignment = 4; static const bool StackKeptAligned = true; // NativeFrameSize is the size of return adress on stack in AsmJS functions. static const uint32_t NativeFrameSize = sizeof(void*); -static const uint32_t AlignmentAtAsmJSPrologue = 0; -static const uint32_t AlignmentMidPrologue = NativeFrameSize; +static const uint32_t AlignmentAtAsmJSPrologue = sizeof(void*); static const Scale ScalePointer = TimesFour; diff --git a/js/src/jit/mips/CodeGenerator-mips.cpp b/js/src/jit/mips/CodeGenerator-mips.cpp index 61013caf708..a68a4d5caf5 100644 --- a/js/src/jit/mips/CodeGenerator-mips.cpp +++ b/js/src/jit/mips/CodeGenerator-mips.cpp @@ -52,7 +52,7 @@ CodeGeneratorMIPS::generateAsmJSPrologue(Label *stackOverflowLabel) { JS_ASSERT(gen->compilingAsmJS()); - masm.Push(ra); + masm.push(ra); // The asm.js over-recursed handler wants to be able to assume that SP // points to the return address, so perform the check after pushing ra but @@ -84,18 +84,12 @@ CodeGeneratorMIPS::generateEpilogue() } #endif - if (gen->compilingAsmJS()) { - // Pop the stack we allocated at the start of the function. + if (gen->compilingAsmJS()) masm.freeStack(frameDepth_); - masm.Pop(ra); - masm.abiret(); - MOZ_ASSERT(masm.framePushed() == 0); - } else { - // Pop the stack we allocated at the start of the function. + else masm.freeStack(frameSize()); - MOZ_ASSERT(masm.framePushed() == 0); - masm.ret(); - } + JS_ASSERT(masm.framePushed() == 0); + masm.ret(); return true; } @@ -989,14 +983,8 @@ CodeGeneratorMIPS::toMoveOperand(const LAllocation *a) const if (a->isFloatReg()) { return MoveOperand(ToFloatRegister(a)); } - MOZ_ASSERT((ToStackOffset(a) & 3) == 0); int32_t offset = ToStackOffset(a); - - // The way the stack slots work, we assume that everything from - // depth == 0 downwards is writable. However, since our frame is included - // in this, ensure that the frame gets skipped. - if (gen->compilingAsmJS()) - offset -= AlignmentMidPrologue; + MOZ_ASSERT((offset & 3) == 0); return MoveOperand(StackPointer, offset); } diff --git a/js/src/jit/mips/CodeGenerator-mips.h b/js/src/jit/mips/CodeGenerator-mips.h index b8227b1a0a2..aad26560e1c 100644 --- a/js/src/jit/mips/CodeGenerator-mips.h +++ b/js/src/jit/mips/CodeGenerator-mips.h @@ -33,12 +33,6 @@ class CodeGeneratorMIPS : public CodeGeneratorShared MOZ_ASSERT(a.isMemory()); int32_t offset = ToStackOffset(&a); - // The way the stack slots work, we assume that everything from - // depth == 0 downwards is writable however, since our frame is - // included in this, ensure that the frame gets skipped. - if (gen->compilingAsmJS()) - offset -= AlignmentMidPrologue; - return Address(StackPointer, offset); } @@ -55,12 +49,6 @@ class CodeGeneratorMIPS : public CodeGeneratorShared MOZ_ASSERT(a.isMemory()); int32_t offset = ToStackOffset(&a); - // The way the stack slots work, we assume that everything from - // depth == 0 downwards is writable however, since our frame is - // included in this, ensure that the frame gets skipped. - if (gen->compilingAsmJS()) - offset -= AlignmentMidPrologue; - return Operand(StackPointer, offset); } inline Operand ToOperand(const LAllocation *a) { diff --git a/js/src/jit/mips/MacroAssembler-mips.cpp b/js/src/jit/mips/MacroAssembler-mips.cpp index ee5771cf2f0..a85c07e71d5 100644 --- a/js/src/jit/mips/MacroAssembler-mips.cpp +++ b/js/src/jit/mips/MacroAssembler-mips.cpp @@ -3141,7 +3141,7 @@ MacroAssemblerMIPSCompat::alignPointerUp(Register src, Register dest, uint32_t a } void -MacroAssemblerMIPSCompat::callWithABIPre(uint32_t *stackAdjust) +MacroAssemblerMIPSCompat::callWithABIPre(uint32_t *stackAdjust, bool callFromAsmJS) { MOZ_ASSERT(inCall_); @@ -3152,10 +3152,13 @@ MacroAssemblerMIPSCompat::callWithABIPre(uint32_t *stackAdjust) usedArgSlots_ * sizeof(intptr_t) : NumIntArgRegs * sizeof(intptr_t); + uint32_t alignmentAtPrologue = callFromAsmJS ? AlignmentAtAsmJSPrologue : 0; + if (dynamicAlignment_) { *stackAdjust += ComputeByteAlignment(*stackAdjust, StackAlignment); } else { - *stackAdjust += ComputeByteAlignment(framePushed_ + *stackAdjust, StackAlignment); + *stackAdjust += ComputeByteAlignment(framePushed_ + alignmentAtPrologue + *stackAdjust, + StackAlignment); } reserveStack(*stackAdjust); @@ -3257,7 +3260,7 @@ void MacroAssemblerMIPSCompat::callWithABI(AsmJSImmPtr imm, MoveOp::Type result) { uint32_t stackAdjust; - callWithABIPre(&stackAdjust); + callWithABIPre(&stackAdjust, /* callFromAsmJS = */ true); call(imm); callWithABIPost(stackAdjust, result); } diff --git a/js/src/jit/mips/MacroAssembler-mips.h b/js/src/jit/mips/MacroAssembler-mips.h index 82f1b024e53..0cc3c710a70 100644 --- a/js/src/jit/mips/MacroAssembler-mips.h +++ b/js/src/jit/mips/MacroAssembler-mips.h @@ -422,7 +422,9 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS } void appendCallSite(const CallSiteDesc &desc) { - enoughMemory_ &= append(CallSite(desc, currentOffset(), framePushed_)); + // Add an extra sizeof(void*) to include the return address that was + // pushed by the call instruction (see CallSite::stackDepth). + enoughMemory_ &= append(CallSite(desc, currentOffset(), framePushed_ + sizeof(void*))); } void call(const CallSiteDesc &desc, const Register reg) { @@ -1235,7 +1237,7 @@ public: bool buildOOLFakeExitFrame(void *fakeReturnAddr); private: - void callWithABIPre(uint32_t *stackAdjust); + void callWithABIPre(uint32_t *stackAdjust, bool callFromAsmJS = false); void callWithABIPost(uint32_t stackAdjust, MoveOp::Type result); public: