Commit d43bbd06 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: fix the sqrt issue.

       The test mjsunit/regress/regress-sqrt compares the result of Math.sqrt function
       when using full-compiler and turbofan/crankshaft compiler seperately. But according
       to glibc bug fixing(https://sourceware.org/bugzilla/show_bug.cgi?id=14032). The
       glibc implementation of std::sqrt() (It is invoked in the generated code when
       full-compiler is used.) will change since glibc 2.19.

       In order to keep consistence of Math.sqrt translation in turbofan compiler
       and the pass of mjsunit/regress/regress-sqrt. we translate the Math.sqrt func
       according to the same fix in glibc change.  If the GLIBC version >=2.19, we will
       set the precision to Double. (the original is extended-double).

       This fix is to fix the same issue in https://codereview.chromium.org/606403002 for
       crankshaft. This fix may be ported for crankshaft too.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#31592}
parent 89ffdbc2
...@@ -974,7 +974,21 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -974,7 +974,21 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kX87Float64Sqrt: { case kX87Float64Sqrt: {
__ fstp(0); __ fstp(0);
__ fld_d(MemOperand(esp, 0)); __ fld_d(MemOperand(esp, 0));
#if V8_GLIBC_PREREQ(2, 19)
__ push(edx);
__ sub(esp, Immediate(2 * kIntSize));
__ fnstcw(MemOperand(esp, 4));
__ mov(edx, Immediate(0xfeff));
__ and_(edx, MemOperand(esp, 4));
__ mov(MemOperand(esp, 0), edx);
__ fldcw(MemOperand(esp, 0));
#endif
__ fsqrt(); __ fsqrt();
#if V8_GLIBC_PREREQ(2, 19)
__ fldcw(MemOperand(esp, 4));
__ lea(esp, Operand(esp, 2 * kIntSize));
__ pop(edx);
#endif
__ lea(esp, Operand(esp, kDoubleSize)); __ lea(esp, Operand(esp, kDoubleSize));
break; break;
} }
......
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