no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / js / src / jsmath.h
blobeaa9761d06a6820db1da10ed246d1bcdeab0cdbb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef jsmath_h
8 #define jsmath_h
10 #include <stdint.h>
12 #include "NamespaceImports.h"
14 namespace js {
16 using UnaryMathFunctionType = double (*)(double);
18 // Used for inlining calls to double => double Math functions from JIT code.
19 // Note that this list does not include all unary Math functions: abs and sqrt
20 // for example are missing because the JITs optimize them without a C++ call.
21 enum class UnaryMathFunction : uint8_t {
22 SinNative,
23 SinFdlibm,
24 CosNative,
25 CosFdlibm,
26 TanNative,
27 TanFdlibm,
28 Log,
29 Exp,
30 ACos,
31 ASin,
32 ATan,
33 Log10,
34 Log2,
35 Log1P,
36 ExpM1,
37 CosH,
38 SinH,
39 TanH,
40 ACosH,
41 ASinH,
42 ATanH,
43 Trunc,
44 Cbrt,
45 Floor,
46 Ceil,
47 Round,
50 extern UnaryMathFunctionType GetUnaryMathFunctionPtr(UnaryMathFunction fun);
51 extern const char* GetUnaryMathFunctionName(UnaryMathFunction fun);
54 * JS math functions.
57 extern const JSClass MathClass;
59 extern uint64_t GenerateRandomSeed();
61 // Fill |seed[0]| and |seed[1]| with random bits, suitable for
62 // seeding a XorShift128+ random number generator.
63 extern void GenerateXorShift128PlusSeed(mozilla::Array<uint64_t, 2>& seed);
65 extern double math_random_impl(JSContext* cx);
67 extern double math_abs_impl(double x);
69 extern bool math_abs(JSContext* cx, unsigned argc, js::Value* vp);
71 extern double math_max_impl(double x, double y);
73 extern bool math_max(JSContext* cx, unsigned argc, js::Value* vp);
75 extern double math_min_impl(double x, double y);
77 extern bool math_min(JSContext* cx, unsigned argc, js::Value* vp);
79 extern double math_sqrt_impl(double x);
81 extern bool math_imul_handle(JSContext* cx, HandleValue lhs, HandleValue rhs,
82 MutableHandleValue res);
84 extern bool RoundFloat32(JSContext* cx, HandleValue v, float* out);
86 extern bool RoundFloat32(JSContext* cx, HandleValue arg,
87 MutableHandleValue res);
89 extern double RoundFloat32(double d);
91 extern double math_log_impl(double x);
93 extern bool math_use_fdlibm_for_sin_cos_tan();
95 extern double math_sin_fdlibm_impl(double x);
96 extern double math_sin_native_impl(double x);
98 extern double math_cos_fdlibm_impl(double x);
99 extern double math_cos_native_impl(double x);
101 extern double math_exp_impl(double x);
103 extern double math_tan_fdlibm_impl(double x);
104 extern double math_tan_native_impl(double x);
106 extern double ecmaHypot(double x, double y);
108 extern double hypot3(double x, double y, double z);
110 extern double hypot4(double x, double y, double z, double w);
112 extern bool math_hypot_handle(JSContext* cx, HandleValueArray args,
113 MutableHandleValue res);
115 extern bool math_trunc(JSContext* cx, unsigned argc, Value* vp);
117 extern double ecmaAtan2(double x, double y);
119 extern double math_atan_impl(double x);
121 extern double math_asin_impl(double x);
123 extern double math_acos_impl(double x);
125 extern double math_ceil_impl(double x);
127 extern bool math_floor(JSContext* cx, unsigned argc, Value* vp);
129 extern double math_floor_impl(double x);
131 template <typename T>
132 extern T GetBiggestNumberLessThan(T x);
134 extern double math_round_impl(double x);
136 extern float math_roundf_impl(float x);
138 extern double powi(double x, int32_t y);
140 extern double ecmaPow(double x, double y);
142 extern double math_log10_impl(double x);
144 extern double math_log2_impl(double x);
146 extern double math_log1p_impl(double x);
148 extern double math_expm1_impl(double x);
150 extern double math_cosh_impl(double x);
152 extern double math_sinh_impl(double x);
154 extern double math_tanh_impl(double x);
156 extern double math_acosh_impl(double x);
158 extern double math_asinh_impl(double x);
160 extern double math_atanh_impl(double x);
162 extern double math_trunc_impl(double x);
164 extern float math_truncf_impl(float x);
166 extern double math_sign_impl(double x);
168 extern double math_cbrt_impl(double x);
170 } /* namespace js */
172 #endif /* jsmath_h */