Bug 1024498: Kill NativeFrameSize and rename AsmJSAlignmentAtPrologue into AsmJSSizeOfRetAddr; r=luke

This commit is contained in:
Benjamin Bouvier 2014-06-13 09:51:22 +02:00
Родитель 49477722f8
Коммит cd545ec192
11 изменённых файлов: 41 добавлений и 27 удалений

Просмотреть файл

@ -6039,7 +6039,7 @@ LoadJSContextFromActivation(MacroAssembler &masm, Register activation, Register
static void
AssertStackAlignment(MacroAssembler &masm)
{
JS_ASSERT((AlignmentAtAsmJSPrologue + masm.framePushed()) % StackAlignment == 0);
JS_ASSERT((AsmJSSizeOfRetAddr + masm.framePushed()) % StackAlignment == 0);
#ifdef DEBUG
Label ok;
JS_ASSERT(IsPowerOfTwo(StackAlignment));
@ -6064,7 +6064,7 @@ StackDecrementForCall(MacroAssembler &masm, unsigned bytesToPush)
{
// Include extra padding so that, after pushing the bytesToPush,
// the stack is aligned for a call instruction.
unsigned alreadyPushed = AlignmentAtAsmJSPrologue + masm.framePushed();
unsigned alreadyPushed = AsmJSSizeOfRetAddr + masm.framePushed();
return AlignBytes(alreadyPushed + bytesToPush, StackAlignment) - alreadyPushed;
}
@ -6109,10 +6109,8 @@ GenerateEntry(ModuleCompiler &m, const AsmJSModule::ExportedFunction &exportedFu
// PushRegsInMask(NonVolatileRegs).
masm.setFramePushed(0);
// See AsmJSSizeOfRetAddr comment in Assembler-*.h.
#if defined(JS_CODEGEN_ARM)
// Push lr without incrementing masm.framePushed since this push is
// accounted for by AlignmentAtAsmJSPrologue. The masm.ret at the end will
// pop.
masm.push(lr);
#endif // JS_CODEGEN_ARM
#if defined(JS_CODEGEN_MIPS)
@ -6148,7 +6146,7 @@ GenerateEntry(ModuleCompiler &m, const AsmJSModule::ExportedFunction &exportedFu
Register argv = ABIArgGenerator::NonArgReturnVolatileReg0;
Register scratch = ABIArgGenerator::NonArgReturnVolatileReg1;
#if defined(JS_CODEGEN_X86)
masm.loadPtr(Address(StackPointer, NativeFrameSize + masm.framePushed()), argv);
masm.loadPtr(Address(StackPointer, AsmJSSizeOfRetAddr + masm.framePushed()), argv);
#else
masm.movePtr(IntArgReg0, argv);
#endif
@ -6370,10 +6368,8 @@ GenerateFFIInterpreterExit(ModuleCompiler &m, const ModuleCompiler::ExitDescript
m.setInterpExitOffset(exitIndex);
masm.setFramePushed(0);
// See AsmJSSizeOfRetAddr comment in Assembler-*.h.
#if defined(JS_CODEGEN_ARM)
// Push lr without incrementing masm.framePushed since this push is
// accounted for by AlignmentAtAsmJSPrologue. The masm.ret at the end will
// pop.
masm.push(lr);
#endif
#if defined(JS_CODEGEN_MIPS)
@ -6397,7 +6393,7 @@ GenerateFFIInterpreterExit(ModuleCompiler &m, const ModuleCompiler::ExitDescript
masm.reserveStack(stackDec);
// Fill the argument array.
unsigned offsetToCallerStackArgs = AlignmentAtAsmJSPrologue + masm.framePushed();
unsigned offsetToCallerStackArgs = AsmJSSizeOfRetAddr + masm.framePushed();
Register scratch = ABIArgGenerator::NonArgReturnVolatileReg0;
FillArgumentArray(m, exit.sig().args(), offsetToArgv, offsetToCallerStackArgs, scratch);
@ -6546,12 +6542,10 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit
m.setIonExitOffset(exitIndex);
masm.setFramePushed(0);
// See AsmJSSizeOfRetAddr comment in Assembler-*.h.
#if defined(JS_CODEGEN_X64)
masm.Push(HeapReg);
#elif defined(JS_CODEGEN_ARM)
// Push lr without incrementing masm.framePushed since this push is
// accounted for by AlignmentAtAsmJSPrologue. The masm.ret at the end will
// pop.
masm.push(lr);
// The GlobalReg (r10) and HeapReg (r11) also need to be restored before
@ -6627,7 +6621,7 @@ GenerateFFIIonExit(ModuleCompiler &m, const ModuleCompiler::ExitDescriptor &exit
argOffset += sizeof(Value);
// 5. Fill the arguments
unsigned offsetToCallerStackArgs = masm.framePushed() + NativeFrameSize;
unsigned offsetToCallerStackArgs = masm.framePushed() + AsmJSSizeOfRetAddr;
FillArgumentArray(m, exit.sig().args(), argOffset, offsetToCallerStackArgs, scratch);
argOffset += exit.sig().args().length() * sizeof(Value);
JS_ASSERT(argOffset == offsetToArgs + argBytes);

Просмотреть файл

@ -8706,7 +8706,7 @@ CodeGenerator::visitAsmJSCall(LAsmJSCall *ins)
if (mir->spIncrement())
masm.freeStack(mir->spIncrement());
JS_ASSERT((AlignmentAtAsmJSPrologue + masm.framePushed()) % StackAlignment == 0);
JS_ASSERT((AsmJSSizeOfRetAddr + masm.framePushed()) % StackAlignment == 0);
#ifdef DEBUG
Label ok;

Просмотреть файл

@ -138,8 +138,12 @@ static MOZ_CONSTEXPR_VAR FloatRegister d15 = {FloatRegisters::d15};
static const uint32_t StackAlignment = 8;
static const uint32_t CodeAlignment = 8;
static const bool StackKeptAligned = true;
static const uint32_t NativeFrameSize = sizeof(void*);
static const uint32_t AlignmentAtAsmJSPrologue = sizeof(void*);
// As an invariant across architectures, within asm.js code:
// $sp % StackAlignment = (AsmJSSizeOfRetAddr + masm.framePushed) % StackAlignment
// To achieve this on ARM, the first instruction of the asm.js prologue pushes
// lr without incrementing masm.framePushed.
static const uint32_t AsmJSSizeOfRetAddr = sizeof(void*);
static const Scale ScalePointer = TimesFour;

Просмотреть файл

@ -53,6 +53,7 @@ CodeGeneratorARM::generateAsmJSPrologue(Label *stackOverflowLabel)
{
JS_ASSERT(gen->compilingAsmJS());
// See comment in Assembler-arm.h about AsmJSSizeOfRetAddr.
masm.push(lr);
// The asm.js over-recursed handler wants to be able to assume that SP

Просмотреть файл

@ -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 ? AsmJSSizeOfRetAddr : 0;
if (!dynamicAlignment_) {
*stackAdjust += ComputeByteAlignment(framePushed_ + *stackAdjust + alignmentAtPrologue,

Просмотреть файл

@ -151,9 +151,12 @@ static MOZ_CONSTEXPR_VAR FloatRegister f30 = {FloatRegisters::f30};
static const uint32_t StackAlignment = 8;
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 = sizeof(void*);
// As an invariant across architectures, within asm.js code:
// $sp % StackAlignment = (AsmJSSizeOfRetAddr + masm.framePushed) % StackAlignment
// To achieve this on MIPS, the first instruction of the asm.js prologue pushes
// ra without incrementing masm.framePushed.
static const uint32_t AsmJSSizeOfRetAddr = sizeof(void*);
static const Scale ScalePointer = TimesFour;

Просмотреть файл

@ -52,6 +52,7 @@ CodeGeneratorMIPS::generateAsmJSPrologue(Label *stackOverflowLabel)
{
JS_ASSERT(gen->compilingAsmJS());
// See comment in Assembler-mips.h about AsmJSSizeOfRetAddr.
masm.push(ra);
// The asm.js over-recursed handler wants to be able to assume that SP

Просмотреть файл

@ -69,7 +69,7 @@ CodeGeneratorShared::CodeGeneratorShared(MIRGenerator *gen, LIRGraph *graph, Mac
// relies on the a priori stack adjustment (in the prologue) on platforms
// (like x64) which require the stack to be aligned.
if (StackKeptAligned || gen->needsInitialStackAlignment()) {
unsigned alignmentAtCall = AlignmentAtAsmJSPrologue + frameDepth_;
unsigned alignmentAtCall = AsmJSSizeOfRetAddr + frameDepth_;
if (unsigned rem = alignmentAtCall % StackAlignment)
frameDepth_ += StackAlignment - rem;
}

Просмотреть файл

@ -155,7 +155,7 @@ class CodeGeneratorShared : public LInstructionVisitor
// For arguments to the current function.
inline int32_t ArgToStackOffset(int32_t slot) const {
return masm.framePushed() +
(gen->compilingAsmJS() ? NativeFrameSize : sizeof(IonJSFrameLayout)) +
(gen->compilingAsmJS() ? AsmJSSizeOfRetAddr : sizeof(IonJSFrameLayout)) +
slot;
}

Просмотреть файл

@ -182,8 +182,13 @@ static MOZ_CONSTEXPR_VAR Register PreBarrierReg = rdx;
static const uint32_t StackAlignment = 16;
static const bool StackKeptAligned = false;
static const uint32_t CodeAlignment = 8;
static const uint32_t NativeFrameSize = sizeof(void*);
static const uint32_t AlignmentAtAsmJSPrologue = sizeof(void*);
// As an invariant across architectures, within asm.js code:
// $sp % StackAlignment = (AsmJSSizeOfRetAddr + masm.framePushed) % StackAlignment
// On x64, this naturally falls out of the fact that the 'call' instruction
// pushes the return address on the stack and masm.framePushed = 0 at the first
// instruction of the prologue.
static const uint32_t AsmJSSizeOfRetAddr = sizeof(void*);
static const Scale ScalePointer = TimesEight;

Просмотреть файл

@ -110,8 +110,14 @@ static const uint32_t StackAlignment = 4;
#endif
static const bool StackKeptAligned = false;
static const uint32_t CodeAlignment = 8;
static const uint32_t NativeFrameSize = sizeof(void*);
static const uint32_t AlignmentAtAsmJSPrologue = sizeof(void*);
// As an invariant across architectures, within asm.js code:
// $sp % StackAlignment = (AsmJSSizeOfRetAddr + masm.framePushed) % StackAlignment
// On x86, this naturally falls out of the fact that the 'call' instruction
// pushes the return address on the stack and masm.framePushed = 0 at the first
// instruction of the prologue.
static const uint32_t AsmJSSizeOfRetAddr = sizeof(void*);
struct ImmTag : public Imm32
{
ImmTag(JSValueTag mask)