Bug 899712 - Prevent infinite recursion in fallback asinh, r=jorendorff

--HG--
extra : rebase_source : 1b810304f83b81fd435f3de3350004d0fcffba14
This commit is contained in:
Steve Fink 2013-07-30 12:36:03 -07:00
parent 85ff446e25
commit 1041a33255

View File

@ -1017,7 +1017,9 @@ js::math_acosh(JSContext *cx, unsigned argc, Value *vp)
} }
#if !HAVE_ASINH #if !HAVE_ASINH
double asinh(double x) // Bug 899712 - gcc incorrectly rewrites -asinh(-x) to asinh(x) when overriding
// asinh.
static double my_asinh(double x)
{ {
const double SQUARE_ROOT_EPSILON = sqrt(std::numeric_limits<double>::epsilon()); const double SQUARE_ROOT_EPSILON = sqrt(std::numeric_limits<double>::epsilon());
const double FOURTH_ROOT_EPSILON = sqrt(SQUARE_ROOT_EPSILON); const double FOURTH_ROOT_EPSILON = sqrt(SQUARE_ROOT_EPSILON);
@ -1032,7 +1034,7 @@ double asinh(double x)
else else
return log(x + sqrt(x * x + 1)); return log(x + sqrt(x * x + 1));
} else if (x <= -FOURTH_ROOT_EPSILON) { } else if (x <= -FOURTH_ROOT_EPSILON) {
return -asinh(-x); return -my_asinh(-x);
} else { } else {
// http://functions.wolfram.com/ElementaryFunctions/ArcSinh/06/01/03/01/0001/ // http://functions.wolfram.com/ElementaryFunctions/ArcSinh/06/01/03/01/0001/
// approximation by taylor series in x at 0 up to order 2 // approximation by taylor series in x at 0 up to order 2
@ -1052,7 +1054,11 @@ double asinh(double x)
double double
js::math_asinh_impl(MathCache *cache, double x) js::math_asinh_impl(MathCache *cache, double x)
{ {
#ifdef HAVE_ASINH
return cache->lookup(asinh, x); return cache->lookup(asinh, x);
#else
return cache->lookup(my_asinh, x);
#endif
} }
bool bool