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 var rngstate; // Initialized to a Uint32Array during genesis. | 5 var rngstate; // Initialized to a Uint32Array during genesis. |
6 | 6 |
7 (function(global, utils) { | 7 (function(global, utils) { |
8 "use strict"; | 8 "use strict"; |
9 | 9 |
10 %CheckIsBootstrapping(); | 10 %CheckIsBootstrapping(); |
11 | 11 |
12 // ------------------------------------------------------------------- | 12 // ------------------------------------------------------------------- |
13 // Imports | 13 // Imports |
14 | 14 |
15 var GlobalMath = global.Math; | 15 var GlobalMath = global.Math; |
16 var GlobalObject = global.Object; | 16 var GlobalObject = global.Object; |
17 var InternalArray = utils.InternalArray; | 17 var InternalArray = utils.InternalArray; |
| 18 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
18 | 19 |
19 //------------------------------------------------------------------- | 20 //------------------------------------------------------------------- |
20 | 21 |
21 // ECMA 262 - 15.8.2.1 | 22 // ECMA 262 - 15.8.2.1 |
22 function MathAbs(x) { | 23 function MathAbs(x) { |
23 x = +x; | 24 x = +x; |
24 return (x > 0) ? x : 0 - x; | 25 return (x > 0) ? x : 0 - x; |
25 } | 26 } |
26 | 27 |
27 // ECMA 262 - 15.8.2.2 | 28 // ECMA 262 - 15.8.2.2 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 var approx_hi = MathFloorJS(%_DoubleHi(x) / 3) + 0x2A9F7893; | 282 var approx_hi = MathFloorJS(%_DoubleHi(x) / 3) + 0x2A9F7893; |
282 var approx = %_ConstructDouble(approx_hi, 0); | 283 var approx = %_ConstructDouble(approx_hi, 0); |
283 approx = NEWTON_ITERATION_CBRT(x, approx); | 284 approx = NEWTON_ITERATION_CBRT(x, approx); |
284 approx = NEWTON_ITERATION_CBRT(x, approx); | 285 approx = NEWTON_ITERATION_CBRT(x, approx); |
285 approx = NEWTON_ITERATION_CBRT(x, approx); | 286 approx = NEWTON_ITERATION_CBRT(x, approx); |
286 return NEWTON_ITERATION_CBRT(x, approx); | 287 return NEWTON_ITERATION_CBRT(x, approx); |
287 } | 288 } |
288 | 289 |
289 // ------------------------------------------------------------------- | 290 // ------------------------------------------------------------------- |
290 | 291 |
291 %AddNamedProperty(GlobalMath, symbolToStringTag, "Math", READ_ONLY | DONT_ENUM); | 292 %AddNamedProperty(GlobalMath, toStringTagSymbol, "Math", READ_ONLY | DONT_ENUM); |
292 | 293 |
293 // Set up math constants. | 294 // Set up math constants. |
294 utils.InstallConstants(GlobalMath, [ | 295 utils.InstallConstants(GlobalMath, [ |
295 // ECMA-262, section 15.8.1.1. | 296 // ECMA-262, section 15.8.1.1. |
296 "E", 2.7182818284590452354, | 297 "E", 2.7182818284590452354, |
297 // ECMA-262, section 15.8.1.2. | 298 // ECMA-262, section 15.8.1.2. |
298 "LN10", 2.302585092994046, | 299 "LN10", 2.302585092994046, |
299 // ECMA-262, section 15.8.1.3. | 300 // ECMA-262, section 15.8.1.3. |
300 "LN2", 0.6931471805599453, | 301 "LN2", 0.6931471805599453, |
301 // ECMA-262, section 15.8.1.4. | 302 // ECMA-262, section 15.8.1.4. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 utils.Export(function(to) { | 357 utils.Export(function(to) { |
357 to.MathAbs = MathAbs; | 358 to.MathAbs = MathAbs; |
358 to.MathExp = MathExp; | 359 to.MathExp = MathExp; |
359 to.MathFloor = MathFloorJS; | 360 to.MathFloor = MathFloorJS; |
360 to.IntRandom = MathRandomRaw; | 361 to.IntRandom = MathRandomRaw; |
361 to.MathMax = MathMax; | 362 to.MathMax = MathMax; |
362 to.MathMin = MathMin; | 363 to.MathMin = MathMin; |
363 }); | 364 }); |
364 | 365 |
365 }) | 366 }) |
OLD | NEW |