| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // ES6 draft 09-27-13, section 20.2.2.7. | 220 // ES6 draft 09-27-13, section 20.2.2.7. |
| 221 function MathAtanh(x) { | 221 function MathAtanh(x) { |
| 222 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 222 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
| 223 // Idempotent for +/-0. | 223 // Idempotent for +/-0. |
| 224 if (x === 0) return x; | 224 if (x === 0) return x; |
| 225 // Returns NaN for NaN and +/- Infinity. | 225 // Returns NaN for NaN and +/- Infinity. |
| 226 if (!NUMBER_IS_FINITE(x)) return NAN; | 226 if (!NUMBER_IS_FINITE(x)) return NAN; |
| 227 return 0.5 * MathLog((1 + x) / (1 - x)); | 227 return 0.5 * MathLog((1 + x) / (1 - x)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // ES6 draft 09-27-13, section 20.2.2.22. | |
| 231 function MathLog2(x) { | |
| 232 return MathLog(x) * 1.442695040888963407; // log2(x) = log(x)/log(2). | |
| 233 } | |
| 234 | |
| 235 // ES6 draft 09-27-13, section 20.2.2.17. | 230 // ES6 draft 09-27-13, section 20.2.2.17. |
| 236 function MathHypot(x, y) { // Function length is 2. | 231 function MathHypot(x, y) { // Function length is 2. |
| 237 // We may want to introduce fast paths for two arguments and when | 232 // We may want to introduce fast paths for two arguments and when |
| 238 // normalization to avoid overflow is not necessary. For now, we | 233 // normalization to avoid overflow is not necessary. For now, we |
| 239 // simply assume the general case. | 234 // simply assume the general case. |
| 240 var length = %_ArgumentsLength(); | 235 var length = %_ArgumentsLength(); |
| 241 var args = new InternalArray(length); | 236 var args = new InternalArray(length); |
| 242 var max = 0; | 237 var max = 0; |
| 243 for (var i = 0; i < length; i++) { | 238 for (var i = 0; i < length; i++) { |
| 244 var n = %_Arguments(i); | 239 var n = %_Arguments(i); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 "imul", MathImul, | 352 "imul", MathImul, |
| 358 "sign", MathSign, | 353 "sign", MathSign, |
| 359 "trunc", MathTrunc, | 354 "trunc", MathTrunc, |
| 360 "sinh", MathSinh, // implemented by third_party/fdlibm | 355 "sinh", MathSinh, // implemented by third_party/fdlibm |
| 361 "cosh", MathCosh, // implemented by third_party/fdlibm | 356 "cosh", MathCosh, // implemented by third_party/fdlibm |
| 362 "tanh", MathTanh, | 357 "tanh", MathTanh, |
| 363 "asinh", MathAsinh, | 358 "asinh", MathAsinh, |
| 364 "acosh", MathAcosh, | 359 "acosh", MathAcosh, |
| 365 "atanh", MathAtanh, | 360 "atanh", MathAtanh, |
| 366 "log10", MathLog10, // implemented by third_party/fdlibm | 361 "log10", MathLog10, // implemented by third_party/fdlibm |
| 367 "log2", MathLog2, | 362 "log2", MathLog2, // implemented by third_party/fdlibm |
| 368 "hypot", MathHypot, | 363 "hypot", MathHypot, |
| 369 "fround", MathFroundJS, | 364 "fround", MathFroundJS, |
| 370 "clz32", MathClz32, | 365 "clz32", MathClz32, |
| 371 "cbrt", MathCbrt, | 366 "cbrt", MathCbrt, |
| 372 "log1p", MathLog1p, // implemented by third_party/fdlibm | 367 "log1p", MathLog1p, // implemented by third_party/fdlibm |
| 373 "expm1", MathExpm1 // implemented by third_party/fdlibm | 368 "expm1", MathExpm1 // implemented by third_party/fdlibm |
| 374 )); | 369 )); |
| 375 | 370 |
| 376 %SetInlineBuiltinFlag(MathCeil); | 371 %SetInlineBuiltinFlag(MathCeil); |
| 377 %SetInlineBuiltinFlag(MathRandom); | 372 %SetInlineBuiltinFlag(MathRandom); |
| 378 %SetInlineBuiltinFlag(MathSin); | 373 %SetInlineBuiltinFlag(MathSin); |
| 379 %SetInlineBuiltinFlag(MathCos); | 374 %SetInlineBuiltinFlag(MathCos); |
| 380 } | 375 } |
| 381 | 376 |
| 382 SetUpMath(); | 377 SetUpMath(); |
| OLD | NEW |