OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Object = global.Object; | 9 // var $Object = global.Object; |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 // ES6 draft 09-27-13, section 20.2.2.34. | 180 // ES6 draft 09-27-13, section 20.2.2.34. |
181 function MathTrunc(x) { | 181 function MathTrunc(x) { |
182 x = TO_NUMBER_INLINE(x); | 182 x = TO_NUMBER_INLINE(x); |
183 if (x > 0) return MathFloor(x); | 183 if (x > 0) return MathFloor(x); |
184 if (x < 0) return MathCeil(x); | 184 if (x < 0) return MathCeil(x); |
185 // -0, 0 or NaN. | 185 // -0, 0 or NaN. |
186 return x; | 186 return x; |
187 } | 187 } |
188 | 188 |
189 // ES6 draft 09-27-13, section 20.2.2.30. | |
190 function MathSinh(x) { | |
191 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | |
192 // Idempotent for NaN, +/-0 and +/-Infinity. | |
193 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; | |
194 return (MathExp(x) - MathExp(-x)) / 2; | |
195 } | |
196 | |
197 // ES6 draft 09-27-13, section 20.2.2.12. | 189 // ES6 draft 09-27-13, section 20.2.2.12. |
198 function MathCosh(x) { | 190 function MathCosh(x) { |
199 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 191 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
200 if (!NUMBER_IS_FINITE(x)) return MathAbs(x); | 192 if (!NUMBER_IS_FINITE(x)) return MathAbs(x); |
201 return (MathExp(x) + MathExp(-x)) / 2; | 193 return (MathExp(x) + MathExp(-x)) / 2; |
202 } | 194 } |
203 | 195 |
204 // ES6 draft 09-27-13, section 20.2.2.33. | 196 // ES6 draft 09-27-13, section 20.2.2.33. |
205 function MathTanh(x) { | 197 function MathTanh(x) { |
206 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 198 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 "sin", MathSin, // implemented by third_party/fdlibm | 361 "sin", MathSin, // implemented by third_party/fdlibm |
370 "sqrt", MathSqrt, | 362 "sqrt", MathSqrt, |
371 "tan", MathTan, // implemented by third_party/fdlibm | 363 "tan", MathTan, // implemented by third_party/fdlibm |
372 "atan2", MathAtan2JS, | 364 "atan2", MathAtan2JS, |
373 "pow", MathPow, | 365 "pow", MathPow, |
374 "max", MathMax, | 366 "max", MathMax, |
375 "min", MathMin, | 367 "min", MathMin, |
376 "imul", MathImul, | 368 "imul", MathImul, |
377 "sign", MathSign, | 369 "sign", MathSign, |
378 "trunc", MathTrunc, | 370 "trunc", MathTrunc, |
379 "sinh", MathSinh, | 371 "sinh", MathSinh, // implemented by third_party/fdlibm |
380 "cosh", MathCosh, | 372 "cosh", MathCosh, |
381 "tanh", MathTanh, | 373 "tanh", MathTanh, |
382 "asinh", MathAsinh, | 374 "asinh", MathAsinh, |
383 "acosh", MathAcosh, | 375 "acosh", MathAcosh, |
384 "atanh", MathAtanh, | 376 "atanh", MathAtanh, |
385 "log10", MathLog10, | 377 "log10", MathLog10, |
386 "log2", MathLog2, | 378 "log2", MathLog2, |
387 "hypot", MathHypot, | 379 "hypot", MathHypot, |
388 "fround", MathFroundJS, | 380 "fround", MathFroundJS, |
389 "clz32", MathClz32, | 381 "clz32", MathClz32, |
390 "cbrt", MathCbrt, | 382 "cbrt", MathCbrt, |
391 "log1p", MathLog1p, // implemented by third_party/fdlibm | 383 "log1p", MathLog1p, // implemented by third_party/fdlibm |
392 "expm1", MathExpm1 // implemented by third_party/fdlibm | 384 "expm1", MathExpm1 // implemented by third_party/fdlibm |
393 )); | 385 )); |
394 | 386 |
395 %SetInlineBuiltinFlag(MathCeil); | 387 %SetInlineBuiltinFlag(MathCeil); |
396 %SetInlineBuiltinFlag(MathRandom); | 388 %SetInlineBuiltinFlag(MathRandom); |
397 %SetInlineBuiltinFlag(MathSin); | 389 %SetInlineBuiltinFlag(MathSin); |
398 %SetInlineBuiltinFlag(MathCos); | 390 %SetInlineBuiltinFlag(MathCos); |
399 } | 391 } |
400 | 392 |
401 SetUpMath(); | 393 SetUpMath(); |
OLD | NEW |