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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Non-standard extension. | 166 // Non-standard extension. |
167 function MathImul(x, y) { | 167 function MathImul(x, y) { |
168 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); | 168 return %NumberImul(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); |
169 } | 169 } |
170 | 170 |
171 // ES6 draft 09-27-13, section 20.2.2.28. | 171 // ES6 draft 09-27-13, section 20.2.2.28. |
172 function MathSign(x) { | 172 function MathSign(x) { |
173 x = TO_NUMBER_INLINE(x); | 173 x = TO_NUMBER_INLINE(x); |
174 if (x > 0) return 1; | 174 if (x > 0) return 1; |
175 if (x < 0) return -1; | 175 if (x < 0) return -1; |
176 if (x === 0) return x; | 176 // -0, 0 or NaN. |
177 return NAN; | 177 return x; |
178 } | 178 } |
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 if (x === 0) return x; | 185 // -0, 0 or NaN. |
186 return NAN; | 186 return x; |
187 } | 187 } |
188 | 188 |
189 // ES6 draft 09-27-13, section 20.2.2.30. | 189 // ES6 draft 09-27-13, section 20.2.2.30. |
190 function MathSinh(x) { | 190 function MathSinh(x) { |
191 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 191 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
192 // Idempotent for NaN, +/-0 and +/-Infinity. | 192 // Idempotent for NaN, +/-0 and +/-Infinity. |
193 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; | 193 if (x === 0 || !NUMBER_IS_FINITE(x)) return x; |
194 return (MathExp(x) - MathExp(-x)) / 2; | 194 return (MathExp(x) - MathExp(-x)) / 2; |
195 } | 195 } |
196 | 196 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 "expm1", MathExpm1 // implemented by third_party/fdlibm | 392 "expm1", MathExpm1 // implemented by third_party/fdlibm |
393 )); | 393 )); |
394 | 394 |
395 %SetInlineBuiltinFlag(MathCeil); | 395 %SetInlineBuiltinFlag(MathCeil); |
396 %SetInlineBuiltinFlag(MathRandom); | 396 %SetInlineBuiltinFlag(MathRandom); |
397 %SetInlineBuiltinFlag(MathSin); | 397 %SetInlineBuiltinFlag(MathSin); |
398 %SetInlineBuiltinFlag(MathCos); | 398 %SetInlineBuiltinFlag(MathCos); |
399 } | 399 } |
400 | 400 |
401 SetUpMath(); | 401 SetUpMath(); |
OLD | NEW |