OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 } | 167 } |
168 return r; | 168 return r; |
169 } | 169 } |
170 | 170 |
171 // ECMA 262 - 15.8.2.13 | 171 // ECMA 262 - 15.8.2.13 |
172 function MathPow(x, y) { | 172 function MathPow(x, y) { |
173 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); | 173 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); |
174 } | 174 } |
175 | 175 |
176 // ECMA 262 - 15.8.2.14 | 176 // ECMA 262 - 15.8.2.14 |
177 // random0 and random1 are initialized during genesis. | |
177 function MathRandom() { | 178 function MathRandom() { |
178 return %_RandomHeapNumber(); | 179 var r0 = (MathImul(18273, random0 & 0xFFFF) + (random0 >>> 16)) | 0; |
180 random0 = r0; | |
Michael Starzinger
2013/11/11 14:11:12
I am not sure about the sequence of the initializa
Sven Panne
2013/11/12 07:09:12
Done.
| |
181 var r1 = (MathImul(36969, random1 & 0xFFFF) + (random1 >>> 16)) | 0; | |
182 random1 = r1; | |
183 var x = ((r0 << 14) + (r1 & 0x3FFFF)) | 0; | |
184 return (x < 0 ? (x + 0x100000000) : x) / 0x100000000; | |
179 } | 185 } |
180 | 186 |
181 // ECMA 262 - 15.8.2.15 | 187 // ECMA 262 - 15.8.2.15 |
182 function MathRound(x) { | 188 function MathRound(x) { |
183 return %RoundNumber(TO_NUMBER_INLINE(x)); | 189 return %RoundNumber(TO_NUMBER_INLINE(x)); |
184 } | 190 } |
185 | 191 |
186 // ECMA 262 - 15.8.2.16 | 192 // ECMA 262 - 15.8.2.16 |
187 function MathSin(x) { | 193 function MathSin(x) { |
188 return %_MathSin(TO_NUMBER_INLINE(x)); | 194 return %_MathSin(TO_NUMBER_INLINE(x)); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 "tan", MathTan, | 278 "tan", MathTan, |
273 "atan2", MathAtan2, | 279 "atan2", MathAtan2, |
274 "pow", MathPow, | 280 "pow", MathPow, |
275 "max", MathMax, | 281 "max", MathMax, |
276 "min", MathMin, | 282 "min", MathMin, |
277 "imul", MathImul | 283 "imul", MathImul |
278 )); | 284 )); |
279 } | 285 } |
280 | 286 |
281 SetUpMath(); | 287 SetUpMath(); |
OLD | NEW |