Bug 885183 - Use Push and Pop in more places instead of manually adjusting the stack pointer and loading and storing. r=sstangl

This commit is contained in:
Dan Gohman 2013-06-26 07:15:14 -07:00
parent b8d640eeab
commit 16c94bc21d
10 changed files with 49 additions and 14 deletions

View File

@ -1125,8 +1125,7 @@ bool
CodeGenerator::visitParDump(LParDump *lir)
{
ValueOperand value = ToValue(lir, 0);
masm.reserveStack(sizeof(Value));
masm.storeValue(value, Address(StackPointer, 0));
masm.Push(value);
masm.movePtr(StackPointer, CallTempReg0);
masm.setupUnalignedABICall(1, CallTempReg1);
masm.passABIArg(CallTempReg0);

View File

@ -1227,12 +1227,10 @@ MacroAssembler::popRooted(VMFunction::RootType rootType, Register cellReg,
case VMFunction::RootPropertyName:
case VMFunction::RootFunction:
case VMFunction::RootCell:
loadPtr(Address(StackPointer, 0), cellReg);
freeStack(sizeof(void *));
Pop(cellReg);
break;
case VMFunction::RootValue:
loadValue(Address(StackPointer, 0), valueReg);
freeStack(sizeof(Value));
Pop(valueReg);
break;
}
}

View File

@ -359,6 +359,7 @@ class MacroAssembler : public MacroAssemblerSpecific
}
using MacroAssemblerSpecific::Push;
using MacroAssemblerSpecific::Pop;
void Push(jsid id, Register scratchReg) {
if (JSID_IS_GCTHING(id)) {

View File

@ -990,6 +990,14 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM
ma_push(reg);
}
void pushValue(const Address &addr);
void Push(const ValueOperand &val) {
pushValue(val);
framePushed_ += sizeof(Value);
}
void Pop(const ValueOperand &val) {
popValue(val);
framePushed_ -= sizeof(Value);
}
void storePayload(const Value &val, Operand dest);
void storePayload(Register src, Operand dest);
void storePayload(const Value &val, Register base, Register index, int32_t shift = defaultShift);

View File

@ -178,10 +178,15 @@ class MacroAssemblerX86Shared : public Assembler
return pushWithPatch(word);
}
void Pop(const Register &reg) {
pop(reg);
template <typename T>
void Pop(const T &t) {
pop(t);
framePushed_ -= STACK_SLOT_SIZE;
}
void Pop(const FloatRegister &t) {
pop(t);
framePushed_ -= sizeof(double);
}
void implicitPop(uint32_t args) {
JS_ASSERT(args % STACK_SLOT_SIZE == 0);
framePushed_ -= args;

View File

@ -310,6 +310,7 @@ class Assembler : public AssemblerX86Shared
using AssemblerX86Shared::j;
using AssemblerX86Shared::jmp;
using AssemblerX86Shared::push;
using AssemblerX86Shared::pop;
static uint8_t *PatchableJumpAddress(IonCode *code, size_t index);
static void PatchJumpEntry(uint8_t *entry, uint8_t *target);
@ -346,7 +347,7 @@ class Assembler : public AssemblerX86Shared
}
}
void push(const FloatRegister &src) {
subq(Imm32(sizeof(void*)), StackPointer);
subq(Imm32(sizeof(double)), StackPointer);
movsd(src, Operand(StackPointer, 0));
}
CodeOffsetLabel pushWithPatch(const ImmWord &word) {
@ -355,6 +356,11 @@ class Assembler : public AssemblerX86Shared
return label;
}
void pop(const FloatRegister &src) {
movsd(Operand(StackPointer, 0), src);
addq(Imm32(sizeof(double)), StackPointer);
}
CodeOffsetLabel movWithPatch(const ImmWord &word, const Register &dest) {
movq(word, dest);
return masm.currentOffset();

View File

@ -53,6 +53,7 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
public:
using MacroAssemblerX86Shared::call;
using MacroAssemblerX86Shared::Push;
using MacroAssemblerX86Shared::Pop;
using MacroAssemblerX86Shared::callWithExitFrame;
using MacroAssemblerX86Shared::branch32;
@ -189,6 +190,10 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared
void pushValue(const Address &addr) {
push(Operand(addr));
}
void Pop(const ValueOperand &val) {
popValue(val);
framePushed_ -= sizeof(Value);
}
void moveValue(const Value &val, const Register &dest) {
jsval_layout jv = JSVAL_TO_IMPL(val);

View File

@ -256,6 +256,7 @@ class Assembler : public AssemblerX86Shared
using AssemblerX86Shared::cmpl;
using AssemblerX86Shared::call;
using AssemblerX86Shared::push;
using AssemblerX86Shared::pop;
static void TraceJumpRelocations(JSTracer *trc, IonCode *code, CompactBufferReader &reader);
@ -282,6 +283,11 @@ class Assembler : public AssemblerX86Shared
return masm.currentOffset();
}
void pop(const FloatRegister &src) {
movsd(Operand(StackPointer, 0), src);
addl(Imm32(sizeof(double)), StackPointer);
}
CodeOffsetLabel movWithPatch(const ImmWord &word, const Register &dest) {
movl(Imm32(word.value), dest);
return masm.currentOffset();

View File

@ -55,6 +55,7 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
public:
using MacroAssemblerX86Shared::Push;
using MacroAssemblerX86Shared::Pop;
using MacroAssemblerX86Shared::callWithExitFrame;
using MacroAssemblerX86Shared::branch32;
@ -204,6 +205,14 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared
push(tagOf(addr));
push(payloadOf(addr));
}
void Push(const ValueOperand &val) {
pushValue(val);
framePushed_ += sizeof(Value);
}
void Pop(const ValueOperand &val) {
popValue(val);
framePushed_ -= sizeof(Value);
}
void storePayload(const Value &val, Operand dest) {
jsval_layout jv = JSVAL_TO_IMPL(val);
if (val.isMarkable())

View File

@ -539,7 +539,7 @@ IonRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
switch (f.outParam) {
case Type_Value:
outReg = regs.takeAny();
masm.reserveStack(sizeof(Value));
masm.Push(UndefinedValue());
masm.movl(esp, outReg);
break;
@ -626,14 +626,12 @@ IonRuntime::generateVMWrapper(JSContext *cx, const VMFunction &f)
break;
case Type_Value:
masm.loadValue(Address(esp, 0), JSReturnOperand);
masm.freeStack(sizeof(Value));
masm.Pop(JSReturnOperand);
break;
case Type_Int32:
case Type_Pointer:
masm.load32(Address(esp, 0), ReturnReg);
masm.freeStack(sizeof(int32_t));
masm.Pop(ReturnReg);
break;
default: