Commit 196a0d3a authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [builtins] Introduce proper Float64Log1p operator.

  port 7ceed92a (r36914)

  original commit message:
  Import base::ieee754::log1p() from fdlibm and introduce a Float64Log1p
  TurboFan operator based on that, similar to what we do for Float64Log.
  Rewrite Math.log1p() as TurboFan builtin and use that operator to also
  inline Math.log1p() into optimized TurboFan functions.

  Also unify the handling of the special IEEE 754 functions somewhat in
  the TurboFan backends. At some point we can hopefully express this
  completely in the InstructionSelector (once we have an idea what to do
  with the ST(0) return issue on IA-32/X87).

BUG=

  Drive-by-fix: Add some more test coverage for the log function.
Review-Url: https://codereview.chromium.org/2094953002

Cr-Commit-Position: refs/heads/master@{#37255}
parent 235ed700
......@@ -370,6 +370,26 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
} \
} while (0)
#define ASSEMBLE_IEEE754_UNOP(name) \
do { \
/* Saves the esp into ebx */ \
__ push(ebx); \
__ mov(ebx, esp); \
/* Pass one double as argument on the stack. */ \
__ PrepareCallCFunction(2, eax); \
__ fstp(0); \
/* Load operand from original stack */ \
__ fld_d(MemOperand(ebx, 4)); \
/* Put operand into stack for function call */ \
__ fstp_d(Operand(esp, 0)); \
__ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \
2); \
/* Restore the ebx */ \
__ pop(ebx); \
/* Return value is in st(0) on x87. */ \
__ lea(esp, Operand(esp, kDoubleSize)); \
} while (false)
void CodeGenerator::AssembleDeconstructFrame() {
__ mov(esp, ebp);
__ pop(ebp);
......@@ -703,24 +723,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ lea(i.OutputRegister(), Operand(base, offset.offset()));
break;
}
case kIeee754Float64Log: {
// Saves the esp into ebx
__ push(ebx);
__ mov(ebx, esp);
// Pass one double as argument on the stack.
__ PrepareCallCFunction(2, eax);
__ fstp(0);
// Load operand from original stack
__ fld_d(MemOperand(ebx, 4));
// Put operand into stack for function call
__ fstp_d(Operand(esp, 0));
__ CallCFunction(ExternalReference::ieee754_log_function(isolate()), 2);
// Restore the ebx
__ pop(ebx);
// Return value is in st(0) on x87.
__ lea(esp, Operand(esp, kDoubleSize));
case kIeee754Float64Log:
ASSEMBLE_IEEE754_UNOP(log);
break;
case kIeee754Float64Log1p:
ASSEMBLE_IEEE754_UNOP(log1p);
break;
}
case kX87Add:
if (HasImmediateInput(instr, 1)) {
__ add(i.InputOperand(0), i.InputImmediate(1));
......
......@@ -1009,13 +1009,6 @@ void InstructionSelector::VisitFloat64Abs(Node* node) {
Emit(kX87Float64Abs, g.DefineAsFixed(node, stX_0), 0, nullptr);
}
void InstructionSelector::VisitFloat64Log(Node* node) {
X87OperandGenerator g(this);
Emit(kX87PushFloat64, g.NoOutput(), g.Use(node->InputAt(0)));
Emit(kIeee754Float64Log, g.DefineAsFixed(node, stX_0), 0, nullptr)
->MarkAsCall();
}
void InstructionSelector::VisitFloat32Sqrt(Node* node) {
X87OperandGenerator g(this);
Emit(kX87PushFloat32, g.NoOutput(), g.Use(node->InputAt(0)));
......@@ -1094,6 +1087,13 @@ void InstructionSelector::VisitFloat32Neg(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitFloat64Neg(Node* node) { UNREACHABLE(); }
void InstructionSelector::VisitFloat64Ieee754Unop(Node* node,
InstructionCode opcode) {
X87OperandGenerator g(this);
Emit(kX87PushFloat64, g.NoOutput(), g.Use(node->InputAt(0)));
Emit(opcode, g.DefineAsFixed(node, stX_0), 0, nullptr)->MarkAsCall();
}
void InstructionSelector::EmitPrepareArguments(
ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor,
Node* node) {
......
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