Commit 014e42a8 authored by whesse@chromium.org's avatar whesse@chromium.org

Fix unary sub IC heap number code on x64: an untagged double was pushed on the stack and GCd.

BUG=1352
TEST=mjsunit/math-abs

Review URL: http://codereview.chromium.org/6901150

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7742 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 19e9667b
...@@ -710,9 +710,8 @@ void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, ...@@ -710,9 +710,8 @@ void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm,
__ j(not_equal, slow); __ j(not_equal, slow);
if (mode_ == UNARY_OVERWRITE) { if (mode_ == UNARY_OVERWRITE) {
__ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); __ xor_(FieldOperand(eax, HeapNumber::kExponentOffset),
__ xor_(edx, HeapNumber::kSignMask); // Flip sign. Immediate(HeapNumber::kSignMask)); // Flip sign.
__ mov(FieldOperand(eax, HeapNumber::kExponentOffset), edx);
} else { } else {
__ mov(edx, Operand(eax)); __ mov(edx, Operand(eax));
// edx: operand // edx: operand
......
...@@ -535,29 +535,33 @@ void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm, ...@@ -535,29 +535,33 @@ void TypeRecordingUnaryOpStub::GenerateHeapNumberCodeSub(MacroAssembler* masm,
Heap::kHeapNumberMapRootIndex); Heap::kHeapNumberMapRootIndex);
__ j(not_equal, slow); __ j(not_equal, slow);
// Operand is a float, negate its value by flipping sign bit. // Operand is a float, negate its value by flipping the sign bit.
__ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset)); if (mode_ == UNARY_OVERWRITE) {
__ Set(kScratchRegister, 0x01); __ Set(kScratchRegister, 0x01);
__ shl(kScratchRegister, Immediate(63)); __ shl(kScratchRegister, Immediate(63));
__ xor_(rdx, kScratchRegister); // Flip sign. __ xor_(FieldOperand(rax, HeapNumber::kValueOffset), kScratchRegister);
// rdx is value to store.
if (mode_ == UNARY_OVERWRITE) {
__ movq(FieldOperand(rax, HeapNumber::kValueOffset), rdx);
} else { } else {
// Allocate a heap number before calculating the answer,
// so we don't have an untagged double around during GC.
Label slow_allocate_heapnumber, heapnumber_allocated; Label slow_allocate_heapnumber, heapnumber_allocated;
__ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber); __ AllocateHeapNumber(rcx, rbx, &slow_allocate_heapnumber);
__ jmp(&heapnumber_allocated); __ jmp(&heapnumber_allocated);
__ bind(&slow_allocate_heapnumber); __ bind(&slow_allocate_heapnumber);
__ EnterInternalFrame(); __ EnterInternalFrame();
__ push(rdx); __ push(rax);
__ CallRuntime(Runtime::kNumberAlloc, 0); __ CallRuntime(Runtime::kNumberAlloc, 0);
__ movq(rcx, rax); __ movq(rcx, rax);
__ pop(rdx); __ pop(rax);
__ LeaveInternalFrame(); __ LeaveInternalFrame();
__ bind(&heapnumber_allocated); __ bind(&heapnumber_allocated);
// rcx: allocated 'empty' number // rcx: allocated 'empty' number
// Copy the double value to the new heap number, flipping the sign.
__ movq(rdx, FieldOperand(rax, HeapNumber::kValueOffset));
__ Set(kScratchRegister, 0x01);
__ shl(kScratchRegister, Immediate(63));
__ xor_(rdx, kScratchRegister); // Flip sign.
__ movq(FieldOperand(rcx, HeapNumber::kValueOffset), rdx); __ movq(FieldOperand(rcx, HeapNumber::kValueOffset), rdx);
__ movq(rax, rcx); __ movq(rax, rcx);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment