| 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(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 function MathRandom() { | 130 function MathRandom() { |
| 131 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; | 131 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; |
| 132 rngstate[0] = r0; | 132 rngstate[0] = r0; |
| 133 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; | 133 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; |
| 134 rngstate[1] = r1; | 134 rngstate[1] = r1; |
| 135 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; | 135 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; |
| 136 // Division by 0x100000000 through multiplication by reciprocal. | 136 // Division by 0x100000000 through multiplication by reciprocal. |
| 137 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; | 137 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; |
| 138 } | 138 } |
| 139 | 139 |
| 140 function MathRandomRaw() { | |
| 141 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; | |
| 142 rngstate[0] = r0; | |
| 143 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; | |
| 144 rngstate[1] = r1; | |
| 145 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; | |
| 146 return x & 0x3fffffff; | |
| 147 } | |
| 148 | 140 |
| 149 // ECMA 262 - 15.8.2.15 | 141 // ECMA 262 - 15.8.2.15 |
| 150 function MathRound(x) { | 142 function MathRound(x) { |
| 151 return %RoundNumber(TO_NUMBER_INLINE(x)); | 143 return %RoundNumber(TO_NUMBER_INLINE(x)); |
| 152 } | 144 } |
| 153 | 145 |
| 154 // ECMA 262 - 15.8.2.17 | 146 // ECMA 262 - 15.8.2.17 |
| 155 function MathSqrtJS(x) { | 147 function MathSqrtJS(x) { |
| 156 return %_MathSqrt(+x); | 148 return %_MathSqrt(+x); |
| 157 } | 149 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 %SetForceInlineFlag(MathSqrtJS); | 351 %SetForceInlineFlag(MathSqrtJS); |
| 360 %SetForceInlineFlag(MathTrunc); | 352 %SetForceInlineFlag(MathTrunc); |
| 361 | 353 |
| 362 // ------------------------------------------------------------------- | 354 // ------------------------------------------------------------------- |
| 363 // Exports | 355 // Exports |
| 364 | 356 |
| 365 utils.Export(function(to) { | 357 utils.Export(function(to) { |
| 366 to.MathAbs = MathAbs; | 358 to.MathAbs = MathAbs; |
| 367 to.MathExp = MathExp; | 359 to.MathExp = MathExp; |
| 368 to.MathFloor = MathFloorJS; | 360 to.MathFloor = MathFloorJS; |
| 369 to.IntRandom = MathRandomRaw; | |
| 370 to.MathMax = MathMax; | 361 to.MathMax = MathMax; |
| 371 to.MathMin = MathMin; | 362 to.MathMin = MathMin; |
| 372 }); | 363 }); |
| 373 | 364 |
| 374 }) | 365 }) |
| OLD | NEW |