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