From bb041d65ee075a3f8142e8d7ab2bbdb17532842d Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Thu, 9 Jan 2014 07:47:58 +0000 Subject: [PATCH] ARM: Implement sqrt in inline assembly. Call VSQRT directly to avoid the tiniest (1ulp) precision error that occurs in the system-supplied sqrt on QNX/ARM. All precision tests in SunSpider are now passing on this platform. BUG= R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/98363010 Patch from Cosmin Truta . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18506 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/codegen-arm.cc | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index b044ca9b30..5477b24a7f 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -347,13 +347,33 @@ OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( } #endif -#undef __ - - UnaryMathFunction CreateSqrtFunction() { - return &sqrt; +#if defined(USE_SIMULATOR) + return &std::sqrt; +#else + size_t actual_size; + byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + if (buffer == NULL) return &std::sqrt; + + MacroAssembler masm(NULL, buffer, static_cast(actual_size)); + + __ GetCFunctionDoubleResult(d0); + __ vsqrt(d0, d0); + __ SetCallCDoubleArguments(d0); + __ Ret(); + + CodeDesc desc; + masm.GetCode(&desc); + ASSERT(!RelocInfo::RequiresRelocation(desc)); + + CPU::FlushICache(buffer, actual_size); + OS::ProtectCode(buffer, actual_size); + return FUNCTION_CAST(buffer); +#endif } +#undef __ + // ------------------------------------------------------------------------- // Platform-specific RuntimeCallHelper functions.