From 727266fcb8b11becf58a298dcd909baa89d2b582 Mon Sep 17 00:00:00 2001 From: "zhengxing.li" Date: Thu, 30 Jun 2016 21:32:01 -0700 Subject: [PATCH] X87: [turbofan] Introduce Float64Pow and NumberPow operators. port e607e12ea0a706a0b8cb109e95f923426094dc09 (r37323) original commit message: Introduce a new machine operator Float64Pow that for now is backed by the existing MathPowStub to start the unification of Math.pow, and at the same time address the main performance issue that TurboFan still has with the imaging-darkroom benchmark in Kraken. Also migrate the Math.pow builtin itself to a TurboFan builtin and remove a few hundred lines of hand-written platform code for special handling of the fullcodegen Math.pow version. BUG= Review-Url: https://codereview.chromium.org/2119773003 Cr-Commit-Position: refs/heads/master@{#37468} --- src/compiler/x87/code-generator-x87.cc | 10 ++++++++ src/x87/code-stubs-x87.cc | 32 +++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/compiler/x87/code-generator-x87.cc b/src/compiler/x87/code-generator-x87.cc index 6bacda0cb6..c2dd40c56b 100644 --- a/src/compiler/x87/code-generator-x87.cc +++ b/src/compiler/x87/code-generator-x87.cc @@ -785,6 +785,16 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( case kIeee754Float64Log10: ASSEMBLE_IEEE754_UNOP(log10); break; + case kIeee754Float64Pow: { + // Keep the x87 FPU stack empty before calling stub code + __ fstp(0); + // Call the MathStub and put return value in stX_0 + MathPowStub stub(isolate(), MathPowStub::DOUBLE); + __ CallStub(&stub); + /* Return value is in st(0) on x87. */ + __ lea(esp, Operand(esp, 2 * kDoubleSize)); + break; + } case kIeee754Float64Sin: __ X87SetFPUCW(0x027F); ASSEMBLE_IEEE754_UNOP(sin); diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 7b069ac629..c5b7896002 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -270,26 +270,26 @@ void FloatingPointHelper::CheckFloatOperands(MacroAssembler* masm, void MathPowStub::Generate(MacroAssembler* masm) { - const Register base = edx; const Register scratch = ecx; - Label call_runtime; - // We will call runtime helper function directly. - if (exponent_type() == ON_STACK) { - // The arguments are still on the stack. - __ bind(&call_runtime); - __ TailCallRuntime(Runtime::kMathPowRT); + // Load the double_exponent into x87 FPU + __ fld_d(Operand(esp, 0 * kDoubleSize + 4)); + // Load the double_base into x87 FPU + __ fld_d(Operand(esp, 1 * kDoubleSize + 4)); - // The stub is called from non-optimized code, which expects the result - // as heap number in exponent. - __ AllocateHeapNumber(eax, scratch, base, &call_runtime); - __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); - __ ret(2 * kPointerSize); - } else { - // Currently it's only called from full-compiler and exponent type is - // ON_STACK. - UNIMPLEMENTED(); + // Call ieee754 runtime directly. + { + AllowExternalCallThatCantCauseGC scope(masm); + __ PrepareCallCFunction(4, scratch); + // Put the double_base parameter in call stack + __ fstp_d(Operand(esp, 0 * kDoubleSize)); + // Put the double_exponent parameter in call stack + __ fstp_d(Operand(esp, 1 * kDoubleSize)); + __ CallCFunction(ExternalReference::power_double_double_function(isolate()), + 4); } + // Return value is in st(0) on ia32. + __ ret(0); }