Chromium Code Reviews| Index: src/x64/code-stubs-x64.cc |
| diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
| index 2ebfa1100b0abf0d7c733d16862ea5173656373f..20738817e90857d7a5565afd3189e265d24b4161 100644 |
| --- a/src/x64/code-stubs-x64.cc |
| +++ b/src/x64/code-stubs-x64.cc |
| @@ -535,28 +535,33 @@ void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, |
| Heap::kHeapNumberMapRootIndex); |
| __ j(not_equal, slow); |
| - // Operand is a float, negate its value by flipping sign bit. |
| - __ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset)); |
| - __ Set(kScratchRegister, 0x01); |
| - __ shl(kScratchRegister, Immediate(63)); |
| - __ xor_(rdx, kScratchRegister); // Flip sign. |
| - // rdx is value to store. |
| - if (mode_ == UNARY_OVERWRITE) { |
| - __ movq(FieldOperand(rax, HeapNumber::kValueOffset), rdx); |
| - } else { |
| + // Allocate a heap number (if necessary) before calculating the answer, |
| + // so we don't have an untagged double around during GC. |
| + if (mode_ != UNARY_OVERWRITE) { |
| Label slow_allocate_heapnumber, heapnumber_allocated; |
| __ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber); |
| __ jmp(&heapnumber_allocated); |
| __ bind(&slow_allocate_heapnumber); |
| __ EnterInternalFrame(); |
| - __ push(rdx); |
| + __ push(rax); |
| __ CallRuntime(Runtime::kNumberAlloc, 0); |
| __ movq(rcx, rax); |
| - __ pop(rdx); |
| + __ pop(rax); |
| __ LeaveInternalFrame(); |
| - |
| __ bind(&heapnumber_allocated); |
| + } |
| + |
| + // Operand is a float, negate its value by flipping sign bit. |
| + if (mode_ == UNARY_OVERWRITE) { |
|
Søren Thygesen Gjesse
2011/05/02 12:46:25
How about hoisting the loading of the scratch regi
|
| + __ Set(kScratchRegister, 0x01); |
| + __ shl(kScratchRegister, Immediate(63)); |
| + __ xor_(FieldOperand(rax, HeapNumber::kValueOffset), kScratchRegister); |
| + } else { |
| + __ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset)); |
| + __ Set(kScratchRegister, 0x01); |
| + __ shl(kScratchRegister, Immediate(63)); |
| + __ xor_(rdx, kScratchRegister); // Flip sign. |
| // rcx: allocated 'empty' number |
| __ movq(FieldOperand(rcx, HeapNumber::kValueOffset), rdx); |
| __ movq(rax, rcx); |