More Math.abs tweaks for Intel platforms.

Made ia32/x64 code more uniform. Minor jump tweaks.

R=mstarzinger@chromium.org

Review URL: https://codereview.chromium.org/20067003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15857 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
svenpanne@chromium.org 2013-07-24 12:17:45 +00:00
parent eaedafad4b
commit 2d6fa933e0
2 changed files with 9 additions and 26 deletions

View File

@ -3722,38 +3722,30 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
factory()->heap_number_map()); factory()->heap_number_map());
DeoptimizeIf(not_equal, instr->environment()); DeoptimizeIf(not_equal, instr->environment());
Label done; Label slow, allocated, done;
Register tmp = input_reg.is(eax) ? ecx : eax; Register tmp = input_reg.is(eax) ? ecx : eax;
Register tmp2 = tmp.is(ecx) ? edx : input_reg.is(ecx) ? edx : ecx; Register tmp2 = tmp.is(ecx) ? edx : input_reg.is(ecx) ? edx : ecx;
// Preserve the value of all registers. // Preserve the value of all registers.
PushSafepointRegistersScope scope(this); PushSafepointRegistersScope scope(this);
Label negative;
__ mov(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset)); __ mov(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset));
// Check the sign of the argument. If the argument is positive, just // Check the sign of the argument. If the argument is positive, just
// return it. We do not need to patch the stack since |input| and // return it. We do not need to patch the stack since |input| and
// |result| are the same register and |input| will be restored // |result| are the same register and |input| will be restored
// unchanged by popping safepoint registers. // unchanged by popping safepoint registers.
__ test(tmp, Immediate(HeapNumber::kSignMask)); __ test(tmp, Immediate(HeapNumber::kSignMask));
__ j(not_zero, &negative); __ j(zero, &done);
__ jmp(&done);
__ bind(&negative);
Label allocated, slow;
__ AllocateHeapNumber(tmp, tmp2, no_reg, &slow); __ AllocateHeapNumber(tmp, tmp2, no_reg, &slow);
__ jmp(&allocated); __ jmp(&allocated, Label::kNear);
// Slow case: Call the runtime system to do the number allocation. // Slow case: Call the runtime system to do the number allocation.
__ bind(&slow); __ bind(&slow);
CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0,
instr, instr->context()); instr, instr->context());
// Set the pointer to the new heap number in tmp. // Set the pointer to the new heap number in tmp.
if (!tmp.is(eax)) __ mov(tmp, eax); if (!tmp.is(eax)) __ mov(tmp, eax);
// Restore input_reg after call to runtime. // Restore input_reg after call to runtime.
__ LoadFromSafepointRegisterSlot(input_reg, input_reg); __ LoadFromSafepointRegisterSlot(input_reg, input_reg);
@ -3773,7 +3765,7 @@ void LCodeGen::EmitIntegerMathAbs(LMathAbs* instr) {
Register input_reg = ToRegister(instr->value()); Register input_reg = ToRegister(instr->value());
__ test(input_reg, Operand(input_reg)); __ test(input_reg, Operand(input_reg));
Label is_positive; Label is_positive;
__ j(not_sign, &is_positive); __ j(not_sign, &is_positive, Label::kNear);
__ neg(input_reg); // Sets flags. __ neg(input_reg); // Sets flags.
DeoptimizeIf(negative, instr->environment()); DeoptimizeIf(negative, instr->environment());
__ bind(&is_positive); __ bind(&is_positive);

View File

@ -3329,38 +3329,29 @@ void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
Heap::kHeapNumberMapRootIndex); Heap::kHeapNumberMapRootIndex);
DeoptimizeIf(not_equal, instr->environment()); DeoptimizeIf(not_equal, instr->environment());
Label done; Label slow, allocated, done;
Register tmp = input_reg.is(rax) ? rcx : rax; Register tmp = input_reg.is(rax) ? rcx : rax;
Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx;
// Preserve the value of all registers. // Preserve the value of all registers.
PushSafepointRegistersScope scope(this); PushSafepointRegistersScope scope(this);
Label negative;
__ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset)); __ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset));
// Check the sign of the argument. If the argument is positive, just // Check the sign of the argument. If the argument is positive, just
// return it. We do not need to patch the stack since |input| and // return it. We do not need to patch the stack since |input| and
// |result| are the same register and |input| will be restored // |result| are the same register and |input| will be restored
// unchanged by popping safepoint registers. // unchanged by popping safepoint registers.
__ testl(tmp, Immediate(HeapNumber::kSignMask)); __ testl(tmp, Immediate(HeapNumber::kSignMask));
__ j(not_zero, &negative); __ j(zero, &done);
__ jmp(&done);
__ bind(&negative);
Label allocated, slow;
__ AllocateHeapNumber(tmp, tmp2, &slow); __ AllocateHeapNumber(tmp, tmp2, &slow);
__ jmp(&allocated); __ jmp(&allocated, Label::kNear);
// Slow case: Call the runtime system to do the number allocation. // Slow case: Call the runtime system to do the number allocation.
__ bind(&slow); __ bind(&slow);
CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr); CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr);
// Set the pointer to the new heap number in tmp. // Set the pointer to the new heap number in tmp.
if (!tmp.is(rax)) { if (!tmp.is(rax)) __ movq(tmp, rax);
__ movq(tmp, rax);
}
// Restore input_reg after call to runtime. // Restore input_reg after call to runtime.
__ LoadFromSafepointRegisterSlot(input_reg, input_reg); __ LoadFromSafepointRegisterSlot(input_reg, input_reg);
@ -3379,7 +3370,7 @@ void LCodeGen::EmitIntegerMathAbs(LMathAbs* instr) {
Register input_reg = ToRegister(instr->value()); Register input_reg = ToRegister(instr->value());
__ testl(input_reg, input_reg); __ testl(input_reg, input_reg);
Label is_positive; Label is_positive;
__ j(not_sign, &is_positive); __ j(not_sign, &is_positive, Label::kNear);
__ negl(input_reg); // Sets flags. __ negl(input_reg); // Sets flags.
DeoptimizeIf(negative, instr->environment()); DeoptimizeIf(negative, instr->environment());
__ bind(&is_positive); __ bind(&is_positive);