Port r18506 (
c7b2885)
Original commit message:
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=plind44@gmail.com
Review URL: https://codereview.chromium.org/
131263003
Patch from Balazs Kilvady <kilvadyb@homejinni.com>.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18523
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
}
#endif
-#undef __
+UnaryMathFunction CreateSqrtFunction() {
+#if defined(USE_SIMULATOR)
+ return &std::sqrt;
+#else
+ size_t actual_size;
+ byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
+ if (buffer == NULL) return &std::sqrt;
+ MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
-UnaryMathFunction CreateSqrtFunction() {
- return &sqrt;
+ __ GetFromCDoubleArguments(f12);
+ __ sqrt_d(f0, f12);
+ __ SetForCDoubleResult(f0);
+ __ Ret();
+
+ CodeDesc desc;
+ masm.GetCode(&desc);
+ ASSERT(!RelocInfo::RequiresRelocation(desc));
+
+ CPU::FlushICache(buffer, actual_size);
+ OS::ProtectCode(buffer, actual_size);
+ return FUNCTION_CAST<UnaryMathFunction>(buffer);
+#endif
}
+#undef __
+
// -------------------------------------------------------------------------
// Platform-specific RuntimeCallHelper functions.
}
+void MacroAssembler::GetFromCDoubleArguments(const DoubleRegister dst) {
+ if (IsMipsSoftFloatABI) {
+ Move(dst, a0, a1);
+ } else {
+ Move(dst, f12); // Reg f12 is o32 ABI FP first argument value.
+ }
+}
+
+
void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg) {
if (!IsMipsSoftFloatABI) {
Move(f12, dreg);
}
+void MacroAssembler::SetForCDoubleResult(DoubleRegister dreg) {
+ if (!IsMipsSoftFloatABI) {
+ Move(f0, dreg);
+ } else {
+ Move(v0, v1, dreg);
+ }
+}
+
+
void MacroAssembler::SetCallCDoubleArguments(DoubleRegister dreg1,
DoubleRegister dreg2) {
if (!IsMipsSoftFloatABI) {
int num_reg_arguments,
int num_double_arguments);
void GetCFunctionDoubleResult(const DoubleRegister dst);
+ void GetFromCDoubleArguments(const DoubleRegister dst);
// There are two ways of passing double arguments on MIPS, depending on
// whether soft or hard floating point ABI is used. These functions
void SetCallCDoubleArguments(DoubleRegister dreg);
void SetCallCDoubleArguments(DoubleRegister dreg1, DoubleRegister dreg2);
void SetCallCDoubleArguments(DoubleRegister dreg, Register reg);
+ void SetForCDoubleResult(DoubleRegister dreg);
// Calls an API function. Allocates HandleScope, extracts returned value
// from handle and propagates exceptions. Restores context. stack_space