Bug 780597 - Fix move emitter breakCycle to handle spilled registers. r=dvander

This commit is contained in:
Jan de Mooij 2012-08-06 22:42:30 +02:00
parent 9c45c01c55
commit 80cca94870
2 changed files with 26 additions and 3 deletions

View File

@ -85,7 +85,7 @@ MoveEmitterARM::tempReg()
// For now, just pick r12/ip as the eviction point. This is totally
// random, and if it ends up being bad, we can use actual heuristics later.
spilledReg_ = Register::FromCode(12);
spilledReg_ = r12;
if (pushedAtSpill_ == -1) {
masm.Push(spilledReg_);
pushedAtSpill_ = masm.framePushed();
@ -119,6 +119,11 @@ MoveEmitterARM::breakCycle(const MoveOperand &from, const MoveOperand &to, Move:
masm.ma_ldr(toOperand(to, false), temp);
masm.ma_str(temp, cycleSlot());
} else {
if (to.reg() == spilledReg_) {
// If the destination was spilled, restore it first.
masm.ma_ldr(spillSlot(), spilledReg_);
spilledReg_ = InvalidReg;
}
masm.ma_str(to.reg(), cycleSlot());
}
}
@ -147,6 +152,10 @@ MoveEmitterARM::completeCycle(const MoveOperand &from, const MoveOperand &to, Mo
masm.ma_ldr(cycleSlot(), temp);
masm.ma_str(temp, toOperand(to, false));
} else {
if (to.reg() == spilledReg_) {
// Make sure we don't re-clobber the spilled register later.
spilledReg_ = InvalidReg;
}
masm.ma_ldr(cycleSlot(), to.reg());
}
}

View File

@ -75,9 +75,14 @@ MoveEmitterX86::tempReg()
if (spilledReg_ != InvalidReg)
return spilledReg_;
// For now, just pick ecx/rcx as the eviction point. This is totally
// For now, just pick edx/rdx as the eviction point. This is totally
// random, and if it ends up being bad, we can use actual heuristics later.
spilledReg_ = Register::FromCode(2);
spilledReg_ = edx;
#ifdef JS_CPU_X64
JS_ASSERT(edx == rdx);
#endif
if (pushedAtSpill_ == -1) {
masm.Push(spilledReg_);
pushedAtSpill_ = masm.framePushed();
@ -109,6 +114,11 @@ MoveEmitterX86::breakCycle(const MoveOperand &from, const MoveOperand &to, Move:
masm.mov(toOperand(to), temp);
masm.mov(temp, cycleSlot());
} else {
if (to.reg() == spilledReg_) {
// If the destination was spilled, restore it first.
masm.mov(spillSlot(), spilledReg_);
spilledReg_ = InvalidReg;
}
masm.mov(to.reg(), cycleSlot());
}
}
@ -136,6 +146,10 @@ MoveEmitterX86::completeCycle(const MoveOperand &from, const MoveOperand &to, Mo
masm.mov(cycleSlot(), temp);
masm.mov(temp, toOperand(to));
} else {
if (to.reg() == spilledReg_) {
// Make sure we don't re-clobber the spilled register later.
spilledReg_ = InvalidReg;
}
masm.mov(cycleSlot(), to.reg());
}
}