From 286458677e2180dd75c941cb4f924dd104289fc9 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 9 Oct 2014 13:11:03 +0200 Subject: [PATCH] Bug 1076670 - Workaround VS2013 64-bit returning +0 instead of -0 for sin(-0). r=luke --- js/src/jsmath.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 05ca2a2e8422..143a3eaa2b4e 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -878,12 +878,18 @@ js::math_round(JSContext *cx, unsigned argc, Value *vp) double js::math_sin_impl(MathCache *cache, double x) { - return cache->lookup(sin, x, MathCache::Sin); + return cache->lookup(math_sin_uncached, x, MathCache::Sin); } double js::math_sin_uncached(double x) { +#ifdef _WIN64 + // Workaround MSVC bug where sin(-0) is +0 instead of -0 on x64 on + // CPUs without FMA3 (pre-Haswell). See bug 1076670. + if (IsNegativeZero(x)) + return -0.0; +#endif return sin(x); }