Index: src/crankshaft/x87/lithium-codegen-x87.cc |
diff --git a/src/crankshaft/x87/lithium-codegen-x87.cc b/src/crankshaft/x87/lithium-codegen-x87.cc |
index fe39fbf8e57c88eb1415f8ec142578e1bd1681b5..3eb24275fef587e5ed3ea66100c8ed01c163e54a 100644 |
--- a/src/crankshaft/x87/lithium-codegen-x87.cc |
+++ b/src/crankshaft/x87/lithium-codegen-x87.cc |
@@ -3348,8 +3348,19 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { |
DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); |
Label slow, allocated, done; |
- Register tmp = input_reg.is(eax) ? ecx : eax; |
- Register tmp2 = tmp.is(ecx) ? edx : input_reg.is(ecx) ? edx : ecx; |
+ uint32_t available_regs = eax.bit() | ecx.bit() | edx.bit() | ebx.bit(); |
+ available_regs &= ~input_reg.bit(); |
+ if (instr->context()->IsRegister()) { |
+ // Make sure that the context isn't overwritten in the AllocateHeapNumber |
+ // macro below. |
+ available_regs &= ~ToRegister(instr->context()).bit(); |
+ } |
+ |
+ Register tmp = |
+ Register::from_code(base::bits::CountTrailingZeros32(available_regs)); |
+ available_regs &= ~tmp.bit(); |
+ Register tmp2 = |
+ Register::from_code(base::bits::CountTrailingZeros32(available_regs)); |
// Preserve the value of all registers. |
PushSafepointRegistersScope scope(this); |