Bug 1001346 - IonMonkey MIPS: Updating asm.js stack alignment (followup for bug 860736). r=luke

This commit is contained in:
Branislav Rankov 2014-06-05 13:02:36 +02:00
parent 1af32f4446
commit 1c08ec5944
6 changed files with 18 additions and 38 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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: