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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 | 138 |
139 // ECMA 262 - 15.8.2.13 | 139 // ECMA 262 - 15.8.2.13 |
140 function MathPow(x, y) { | 140 function MathPow(x, y) { |
141 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); | 141 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); |
142 } | 142 } |
143 | 143 |
144 // ECMA 262 - 15.8.2.14 | 144 // ECMA 262 - 15.8.2.14 |
145 var rngstate; // Initialized to a Uint32Array during genesis. | 145 var rngstate; // Initialized to a Uint32Array during genesis. |
146 function MathRandom() { | 146 function MathRandom() { |
147 var r0 = (MathImul(18273, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; | 147 var r0 = (MathImul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; |
148 rngstate[0] = r0; | 148 rngstate[0] = r0; |
149 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; | 149 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; |
150 rngstate[1] = r1; | 150 rngstate[1] = r1; |
151 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; | 151 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0; |
152 // Division by 0x100000000 through multiplication by reciprocal. | 152 // Division by 0x100000000 through multiplication by reciprocal. |
153 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; | 153 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; |
154 } | 154 } |
155 | 155 |
156 // ECMA 262 - 15.8.2.15 | 156 // ECMA 262 - 15.8.2.15 |
157 function MathRound(x) { | 157 function MathRound(x) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 "expm1", MathExpm1 // implemented by third_party/fdlibm | 377 "expm1", MathExpm1 // implemented by third_party/fdlibm |
378 )); | 378 )); |
379 | 379 |
380 %SetInlineBuiltinFlag(MathCeil); | 380 %SetInlineBuiltinFlag(MathCeil); |
381 %SetInlineBuiltinFlag(MathRandom); | 381 %SetInlineBuiltinFlag(MathRandom); |
382 %SetInlineBuiltinFlag(MathSin); | 382 %SetInlineBuiltinFlag(MathSin); |
383 %SetInlineBuiltinFlag(MathCos); | 383 %SetInlineBuiltinFlag(MathCos); |
384 } | 384 } |
385 | 385 |
386 SetUpMath(); | 386 SetUpMath(); |
OLD | NEW |