зеркало из https://github.com/mozilla/gecko-dev.git
Bug 933257 - Part 5: Use fdlibm in jsmath.cpp. r=jwalden
This commit is contained in:
Родитель
ecaec25491
Коммит
f0aed2b4eb
|
@ -66,6 +66,7 @@ included_inclnames_to_ignore = set([
|
|||
'jsautokw.h', # generated in $OBJDIR
|
||||
'jscustomallocator.h', # provided by embedders; allowed to be missing
|
||||
'js-config.h', # generated in $OBJDIR
|
||||
'fdlibm.h', # fdlibm
|
||||
'pratom.h', # NSPR
|
||||
'prcvar.h', # NSPR
|
||||
'prerror.h', # NSPR
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "fdlibm.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
# include "jswin.h"
|
||||
#endif
|
||||
|
@ -139,14 +141,14 @@ double
|
|||
js::math_acos_impl(MathCache* cache, double x)
|
||||
{
|
||||
ACOS_IF_OUT_OF_RANGE(x);
|
||||
return cache->lookup(acos, x, MathCache::Acos);
|
||||
return cache->lookup(fdlibm::acos, x, MathCache::Acos);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_acos_uncached(double x)
|
||||
{
|
||||
ACOS_IF_OUT_OF_RANGE(x);
|
||||
return acos(x);
|
||||
return fdlibm::acos(x);
|
||||
}
|
||||
|
||||
#undef ACOS_IF_OUT_OF_RANGE
|
||||
|
@ -184,14 +186,14 @@ double
|
|||
js::math_asin_impl(MathCache* cache, double x)
|
||||
{
|
||||
ASIN_IF_OUT_OF_RANGE(x);
|
||||
return cache->lookup(asin, x, MathCache::Asin);
|
||||
return cache->lookup(fdlibm::asin, x, MathCache::Asin);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_asin_uncached(double x)
|
||||
{
|
||||
ASIN_IF_OUT_OF_RANGE(x);
|
||||
return asin(x);
|
||||
return fdlibm::asin(x);
|
||||
}
|
||||
|
||||
#undef ASIN_IF_OUT_OF_RANGE
|
||||
|
@ -222,13 +224,13 @@ js::math_asin(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_atan_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(atan, x, MathCache::Atan);
|
||||
return cache->lookup(fdlibm::atan, x, MathCache::Atan);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_atan_uncached(double x)
|
||||
{
|
||||
return atan(x);
|
||||
return fdlibm::atan(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -281,7 +283,7 @@ js::ecmaAtan2(double y, double x)
|
|||
return y;
|
||||
}
|
||||
#endif
|
||||
return atan2(y, x);
|
||||
return fdlibm::atan2(y, x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -315,7 +317,7 @@ js::math_ceil_impl(double x)
|
|||
if (x < 0 && x > -1.0)
|
||||
return js_copysign(0, -1);
|
||||
#endif
|
||||
return ceil(x);
|
||||
return fdlibm::ceil(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -369,13 +371,13 @@ js::math_clz32(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_cos_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(cos, x, MathCache::Cos);
|
||||
return cache->lookup(fdlibm::cos, x, MathCache::Cos);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_cos_uncached(double x)
|
||||
{
|
||||
return cos(x);
|
||||
return fdlibm::cos(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -417,14 +419,14 @@ double
|
|||
js::math_exp_impl(MathCache* cache, double x)
|
||||
{
|
||||
EXP_IF_OUT_OF_RANGE(x);
|
||||
return cache->lookup(exp, x, MathCache::Exp);
|
||||
return cache->lookup(fdlibm::exp, x, MathCache::Exp);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_exp_uncached(double x)
|
||||
{
|
||||
EXP_IF_OUT_OF_RANGE(x);
|
||||
return exp(x);
|
||||
return fdlibm::exp(x);
|
||||
}
|
||||
|
||||
#undef EXP_IF_OUT_OF_RANGE
|
||||
|
@ -455,7 +457,7 @@ js::math_exp(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_floor_impl(double x)
|
||||
{
|
||||
return floor(x);
|
||||
return fdlibm::floor(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -559,7 +561,7 @@ double
|
|||
js::math_log_uncached(double x)
|
||||
{
|
||||
LOG_IF_OUT_OF_RANGE(x);
|
||||
return log(x);
|
||||
return fdlibm::log(x);
|
||||
}
|
||||
|
||||
#undef LOG_IF_OUT_OF_RANGE
|
||||
|
@ -679,7 +681,7 @@ js::powi(double x, int y)
|
|||
|
||||
double result = 1.0 / p;
|
||||
return (result == 0 && IsInfinite(p))
|
||||
? pow(x, static_cast<double>(y)) // Avoid pow(double, int).
|
||||
? fdlibm::pow(x, static_cast<double>(y)) // Avoid pow(double, int).
|
||||
: result;
|
||||
}
|
||||
|
||||
|
@ -717,11 +719,11 @@ js::ecmaPow(double x, double y)
|
|||
*/
|
||||
if (IsFinite(x) && x != 0.0) {
|
||||
if (y == 0.5)
|
||||
return sqrt(x);
|
||||
return fdlibm::sqrt(x);
|
||||
if (y == -0.5)
|
||||
return 1.0 / sqrt(x);
|
||||
return 1.0 / fdlibm::sqrt(x);
|
||||
}
|
||||
return pow(x, y);
|
||||
return fdlibm::pow(x, y);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -843,7 +845,7 @@ js::math_round_impl(double x)
|
|||
return x;
|
||||
|
||||
double add = (x >= 0) ? GetBiggestNumberLessThan(0.5) : 0.5;
|
||||
return js_copysign(floor(x + add), x);
|
||||
return js_copysign(fdlibm::floor(x + add), x);
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -858,7 +860,7 @@ js::math_roundf_impl(float x)
|
|||
return x;
|
||||
|
||||
float add = (x >= 0) ? GetBiggestNumberLessThan(0.5f) : 0.5f;
|
||||
return js_copysign(floorf(x + add), x);
|
||||
return js_copysign(fdlibm::floorf(x + add), x);
|
||||
}
|
||||
|
||||
bool /* ES5 15.8.2.15. */
|
||||
|
@ -883,13 +885,7 @@ js::math_sin_impl(MathCache* cache, double x)
|
|||
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);
|
||||
return fdlibm::sin(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -966,7 +962,7 @@ js::math_sqrt_handle(JSContext* cx, HandleValue number, MutableHandleValue resul
|
|||
if (!mathCache)
|
||||
return false;
|
||||
|
||||
double z = mathCache->lookup(sqrt, x, MathCache::Sqrt);
|
||||
double z = mathCache->lookup(fdlibm::sqrt, x, MathCache::Sqrt);
|
||||
result.setDouble(z);
|
||||
return true;
|
||||
}
|
||||
|
@ -987,13 +983,13 @@ js::math_sqrt(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_tan_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(tan, x, MathCache::Tan);
|
||||
return cache->lookup(fdlibm::tan, x, MathCache::Tan);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_tan_uncached(double x)
|
||||
{
|
||||
return tan(x);
|
||||
return fdlibm::tan(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1046,13 +1042,13 @@ static bool math_function(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_log10_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(log10, x, MathCache::Log10);
|
||||
return cache->lookup(fdlibm::log10, x, MathCache::Log10);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_log10_uncached(double x)
|
||||
{
|
||||
return log10(x);
|
||||
return fdlibm::log10(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1071,13 +1067,13 @@ double log2(double x)
|
|||
double
|
||||
js::math_log2_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(log2, x, MathCache::Log2);
|
||||
return cache->lookup(fdlibm::log2, x, MathCache::Log2);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_log2_uncached(double x)
|
||||
{
|
||||
return log2(x);
|
||||
return fdlibm::log2(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1114,14 +1110,14 @@ double
|
|||
js::math_log1p_impl(MathCache* cache, double x)
|
||||
{
|
||||
LOG1P_IF_OUT_OF_RANGE(x);
|
||||
return cache->lookup(log1p, x, MathCache::Log1p);
|
||||
return cache->lookup(fdlibm::log1p, x, MathCache::Log1p);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_log1p_uncached(double x)
|
||||
{
|
||||
LOG1P_IF_OUT_OF_RANGE(x);
|
||||
return log1p(x);
|
||||
return fdlibm::log1p(x);
|
||||
}
|
||||
|
||||
#undef LOG1P_IF_OUT_OF_RANGE
|
||||
|
@ -1156,13 +1152,13 @@ double expm1(double x)
|
|||
double
|
||||
js::math_expm1_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(expm1, x, MathCache::Expm1);
|
||||
return cache->lookup(fdlibm::expm1, x, MathCache::Expm1);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_expm1_uncached(double x)
|
||||
{
|
||||
return expm1(x);
|
||||
return fdlibm::expm1(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1185,13 +1181,13 @@ double sqrt1pm1(double x)
|
|||
double
|
||||
js::math_cosh_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(cosh, x, MathCache::Cosh);
|
||||
return cache->lookup(fdlibm::cosh, x, MathCache::Cosh);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_cosh_uncached(double x)
|
||||
{
|
||||
return cosh(x);
|
||||
return fdlibm::cosh(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1203,13 +1199,13 @@ js::math_cosh(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_sinh_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(sinh, x, MathCache::Sinh);
|
||||
return cache->lookup(fdlibm::sinh, x, MathCache::Sinh);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_sinh_uncached(double x)
|
||||
{
|
||||
return sinh(x);
|
||||
return fdlibm::sinh(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1221,13 +1217,13 @@ js::math_sinh(JSContext* cx, unsigned argc, Value* vp)
|
|||
double
|
||||
js::math_tanh_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(tanh, x, MathCache::Tanh);
|
||||
return cache->lookup(fdlibm::tanh, x, MathCache::Tanh);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_tanh_uncached(double x)
|
||||
{
|
||||
return tanh(x);
|
||||
return fdlibm::tanh(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1270,13 +1266,13 @@ double acosh(double x)
|
|||
double
|
||||
js::math_acosh_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(acosh, x, MathCache::Acosh);
|
||||
return cache->lookup(fdlibm::acosh, x, MathCache::Acosh);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_acosh_uncached(double x)
|
||||
{
|
||||
return acosh(x);
|
||||
return fdlibm::acosh(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1324,7 +1320,7 @@ double
|
|||
js::math_asinh_impl(MathCache* cache, double x)
|
||||
{
|
||||
#ifdef HAVE_ASINH
|
||||
return cache->lookup(asinh, x, MathCache::Asinh);
|
||||
return cache->lookup(fdlibm::asinh, x, MathCache::Asinh);
|
||||
#else
|
||||
return cache->lookup(my_asinh, x, MathCache::Asinh);
|
||||
#endif
|
||||
|
@ -1334,7 +1330,7 @@ double
|
|||
js::math_asinh_uncached(double x)
|
||||
{
|
||||
#ifdef HAVE_ASINH
|
||||
return asinh(x);
|
||||
return fdlibm::asinh(x);
|
||||
#else
|
||||
return my_asinh(x);
|
||||
#endif
|
||||
|
@ -1377,13 +1373,13 @@ double atanh(double x)
|
|||
double
|
||||
js::math_atanh_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(atanh, x, MathCache::Atanh);
|
||||
return cache->lookup(fdlibm::atanh, x, MathCache::Atanh);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_atanh_uncached(double x)
|
||||
{
|
||||
return atanh(x);
|
||||
return fdlibm::atanh(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1405,7 +1401,7 @@ js::ecmaHypot(double x, double y)
|
|||
return mozilla::PositiveInfinity<double>();
|
||||
}
|
||||
#endif
|
||||
return hypot(x, y);
|
||||
return fdlibm::hypot(x, y);
|
||||
}
|
||||
|
||||
static inline
|
||||
|
@ -1443,7 +1439,7 @@ js::hypot4(double x, double y, double z, double w)
|
|||
hypot_step(scale, sumsq, z);
|
||||
hypot_step(scale, sumsq, w);
|
||||
|
||||
return scale * sqrt(sumsq);
|
||||
return scale * fdlibm::sqrt(sumsq);
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -1497,7 +1493,7 @@ js::math_hypot_handle(JSContext* cx, HandleValueArray args, MutableHandleValue r
|
|||
|
||||
double result = isInfinite ? PositiveInfinity<double>() :
|
||||
isNaN ? GenericNaN() :
|
||||
scale * sqrt(sumsq);
|
||||
scale * fdlibm::sqrt(sumsq);
|
||||
res.setNumber(result);
|
||||
return true;
|
||||
}
|
||||
|
@ -1505,13 +1501,13 @@ js::math_hypot_handle(JSContext* cx, HandleValueArray args, MutableHandleValue r
|
|||
double
|
||||
js::math_trunc_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(trunc, x, MathCache::Trunc);
|
||||
return cache->lookup(fdlibm::trunc, x, MathCache::Trunc);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_trunc_uncached(double x)
|
||||
{
|
||||
return trunc(x);
|
||||
return fdlibm::trunc(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1562,13 +1558,13 @@ double cbrt(double x)
|
|||
double
|
||||
js::math_cbrt_impl(MathCache* cache, double x)
|
||||
{
|
||||
return cache->lookup(cbrt, x, MathCache::Cbrt);
|
||||
return cache->lookup(fdlibm::cbrt, x, MathCache::Cbrt);
|
||||
}
|
||||
|
||||
double
|
||||
js::math_cbrt_uncached(double x)
|
||||
{
|
||||
return cbrt(x);
|
||||
return fdlibm::cbrt(x);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Загрузка…
Ссылка в новой задаче