X87: Adopt the fix of the sqrt precision issue from TurboFan to CrankShaft.
port 4e00456471
(r31625)
original commit message:
X87: Fix the sqrt precision issue.
In order to resolve the sqrt precision issue described in https://codereview.chromium.org/1425763002/.
we change the implementation of CreateSqrtFunction() implementation of X87 so that the optimize compiler
and full-compiler implementation are unified.
BUG=
Review URL: https://codereview.chromium.org/1470793004
Cr-Commit-Position: refs/heads/master@{#32166}
This commit is contained in:
parent
d9d603c556
commit
fb633b0cc4
@ -3866,65 +3866,11 @@ void LCodeGen::DoMathFround(LMathFround* instr) {
|
||||
|
||||
|
||||
void LCodeGen::DoMathSqrt(LMathSqrt* instr) {
|
||||
X87Register input = ToX87Register(instr->value());
|
||||
X87Register result_reg = ToX87Register(instr->result());
|
||||
Register temp_result = ToRegister(instr->temp1());
|
||||
Register temp = ToRegister(instr->temp2());
|
||||
Label slow, done, smi, finish;
|
||||
DCHECK(result_reg.is(input));
|
||||
|
||||
// Store input into Heap number and call runtime function kMathExpRT.
|
||||
if (FLAG_inline_new) {
|
||||
__ AllocateHeapNumber(temp_result, temp, no_reg, &slow);
|
||||
__ jmp(&done, Label::kNear);
|
||||
}
|
||||
|
||||
// Slow case: Call the runtime system to do the number allocation.
|
||||
__ bind(&slow);
|
||||
{
|
||||
// TODO(3095996): Put a valid pointer value in the stack slot where the
|
||||
// result register is stored, as this register is in the pointer map, but
|
||||
// contains an integer value.
|
||||
__ Move(temp_result, Immediate(0));
|
||||
|
||||
// Preserve the value of all registers.
|
||||
PushSafepointRegistersScope scope(this);
|
||||
|
||||
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
||||
__ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
|
||||
RecordSafepointWithRegisters(
|
||||
instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
|
||||
__ StoreToSafepointRegisterSlot(temp_result, eax);
|
||||
}
|
||||
__ bind(&done);
|
||||
X87LoadForUsage(input);
|
||||
__ fstp_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
|
||||
|
||||
{
|
||||
// Preserve the value of all registers.
|
||||
PushSafepointRegistersScope scope(this);
|
||||
|
||||
__ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
||||
__ push(temp_result);
|
||||
__ CallRuntimeSaveDoubles(Runtime::kMathSqrt);
|
||||
RecordSafepointWithRegisters(instr->pointer_map(), 1,
|
||||
Safepoint::kNoLazyDeopt);
|
||||
__ StoreToSafepointRegisterSlot(temp_result, eax);
|
||||
}
|
||||
X87PrepareToWrite(result_reg);
|
||||
// return value of MathExpRT is Smi or Heap Number.
|
||||
__ JumpIfSmi(temp_result, &smi);
|
||||
// Heap number(double)
|
||||
__ fld_d(FieldOperand(temp_result, HeapNumber::kValueOffset));
|
||||
__ jmp(&finish);
|
||||
// SMI
|
||||
__ bind(&smi);
|
||||
__ SmiUntag(temp_result);
|
||||
__ push(temp_result);
|
||||
__ fild_s(MemOperand(esp, 0));
|
||||
__ pop(temp_result);
|
||||
__ bind(&finish);
|
||||
X87CommitWrite(result_reg);
|
||||
X87Register input_reg = ToX87Register(instr->value());
|
||||
__ X87SetFPUCW(0x027F);
|
||||
X87Fxch(input_reg);
|
||||
__ fsqrt();
|
||||
__ X87SetFPUCW(0x037F);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user