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 (function(global, utils) { | 5 (function(global, utils) { |
6 "use strict"; | 6 "use strict"; |
7 | 7 |
8 %CheckIsBootstrapping(); | 8 %CheckIsBootstrapping(); |
9 | 9 |
10 // ------------------------------------------------------------------- | 10 // ------------------------------------------------------------------- |
(...skipping 11 matching lines...) Expand all Loading... |
22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 22 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
23 | 23 |
24 //------------------------------------------------------------------- | 24 //------------------------------------------------------------------- |
25 | 25 |
26 // ECMA 262 - 15.8.2.1 | 26 // ECMA 262 - 15.8.2.1 |
27 function MathAbs(x) { | 27 function MathAbs(x) { |
28 x = +x; | 28 x = +x; |
29 return (x > 0) ? x : 0 - x; | 29 return (x > 0) ? x : 0 - x; |
30 } | 30 } |
31 | 31 |
| 32 // ECMA 262 - 15.8.2.8 |
| 33 function MathExp(x) { |
| 34 return %MathExpRT(TO_NUMBER(x)); |
| 35 } |
| 36 |
32 // ECMA 262 - 15.8.2.13 | 37 // ECMA 262 - 15.8.2.13 |
33 function MathPowJS(x, y) { | 38 function MathPowJS(x, y) { |
34 return %_MathPow(TO_NUMBER(x), TO_NUMBER(y)); | 39 return %_MathPow(TO_NUMBER(x), TO_NUMBER(y)); |
35 } | 40 } |
36 | 41 |
37 // ECMA 262 - 15.8.2.14 | 42 // ECMA 262 - 15.8.2.14 |
38 function MathRandom() { | 43 function MathRandom() { |
39 // While creating a startup snapshot, %GenerateRandomNumbers returns a | 44 // While creating a startup snapshot, %GenerateRandomNumbers returns a |
40 // normal array containing a single random number, and has to be called for | 45 // normal array containing a single random number, and has to be called for |
41 // every new random number. | 46 // every new random number. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 "PI", 3.1415926535897932, | 177 "PI", 3.1415926535897932, |
173 "SQRT1_2", 0.7071067811865476, | 178 "SQRT1_2", 0.7071067811865476, |
174 "SQRT2", 1.4142135623730951 | 179 "SQRT2", 1.4142135623730951 |
175 ]); | 180 ]); |
176 | 181 |
177 // Set up non-enumerable functions of the Math object and | 182 // Set up non-enumerable functions of the Math object and |
178 // set their names. | 183 // set their names. |
179 utils.InstallFunctions(GlobalMath, DONT_ENUM, [ | 184 utils.InstallFunctions(GlobalMath, DONT_ENUM, [ |
180 "random", MathRandom, | 185 "random", MathRandom, |
181 "abs", MathAbs, | 186 "abs", MathAbs, |
| 187 "exp", MathExp, |
182 "pow", MathPowJS, | 188 "pow", MathPowJS, |
183 "sign", MathSign, | 189 "sign", MathSign, |
184 "asinh", MathAsinh, | 190 "asinh", MathAsinh, |
185 "acosh", MathAcosh, | 191 "acosh", MathAcosh, |
186 "atanh", MathAtanh, | 192 "atanh", MathAtanh, |
187 "hypot", MathHypot, | 193 "hypot", MathHypot, |
188 "cbrt", MathCbrt | 194 "cbrt", MathCbrt |
189 ]); | 195 ]); |
190 | 196 |
191 %SetForceInlineFlag(MathAbs); | 197 %SetForceInlineFlag(MathAbs); |
192 %SetForceInlineFlag(MathRandom); | 198 %SetForceInlineFlag(MathRandom); |
193 %SetForceInlineFlag(MathSign); | 199 %SetForceInlineFlag(MathSign); |
194 | 200 |
195 // ------------------------------------------------------------------- | 201 // ------------------------------------------------------------------- |
196 // Exports | 202 // Exports |
197 | 203 |
198 utils.Export(function(to) { | 204 utils.Export(function(to) { |
199 to.MathAbs = MathAbs; | 205 to.MathAbs = MathAbs; |
| 206 to.MathExp = MathExp; |
200 to.IntRandom = MathRandomRaw; | 207 to.IntRandom = MathRandomRaw; |
201 }); | 208 }); |
202 | 209 |
203 }) | 210 }) |
OLD | NEW |