Index: src/crankshaft/x64/lithium-codegen-x64.cc |
diff --git a/src/crankshaft/x64/lithium-codegen-x64.cc b/src/crankshaft/x64/lithium-codegen-x64.cc |
index 493bfd49f43f7e8b6f50de39c3a30055d3ba6365..67776e4ca9a6b25ad74d5b36d55f4f5c6e0850bb 100644 |
--- a/src/crankshaft/x64/lithium-codegen-x64.cc |
+++ b/src/crankshaft/x64/lithium-codegen-x64.cc |
@@ -3267,8 +3267,19 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { |
DeoptimizeIf(not_equal, instr, Deoptimizer::kNotAHeapNumber); |
Label slow, allocated, done; |
- Register tmp = input_reg.is(rax) ? rcx : rax; |
- Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; |
+ uint32_t available_regs = rax.bit() | rcx.bit() | rdx.bit() | rbx.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); |