Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: src/math.js

Issue 80743002: Use Marsaglia's original random number generator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
167 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y)); 167 return %_MathPow(TO_NUMBER_INLINE(x), TO_NUMBER_INLINE(y));
168 } 168 }
169 169
170 // ECMA 262 - 15.8.2.14 170 // ECMA 262 - 15.8.2.14
171 var rngstate; // Initialized to a Uint32Array during genesis. 171 var rngstate; // Initialized to a Uint32Array during genesis.
172 function MathRandom() { 172 function MathRandom() {
173 var r0 = (MathImul(18273, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0; 173 var r0 = (MathImul(18273, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
174 rngstate[0] = r0; 174 rngstate[0] = r0;
175 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0; 175 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
176 rngstate[1] = r1; 176 rngstate[1] = r1;
177 var x = ((r0 << 14) + (r1 & 0x3FFFF)) | 0; 177 var x = ((r0 << 16) + (r1 & 0xFFFF)) | 0;
178 // Division by 0x100000000 through multiplication by reciprocal. 178 // Division by 0x100000000 through multiplication by reciprocal.
179 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10; 179 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10;
180 } 180 }
181 181
182 // ECMA 262 - 15.8.2.15 182 // ECMA 262 - 15.8.2.15
183 function MathRound(x) { 183 function MathRound(x) {
184 return %RoundNumber(TO_NUMBER_INLINE(x)); 184 return %RoundNumber(TO_NUMBER_INLINE(x));
185 } 185 }
186 186
187 // ECMA 262 - 15.8.2.16 187 // ECMA 262 - 15.8.2.16
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 "min", MathMin, 390 "min", MathMin,
391 "imul", MathImul 391 "imul", MathImul
392 )); 392 ));
393 393
394 %SetInlineBuiltinFlag(MathSin); 394 %SetInlineBuiltinFlag(MathSin);
395 %SetInlineBuiltinFlag(MathCos); 395 %SetInlineBuiltinFlag(MathCos);
396 %SetInlineBuiltinFlag(MathTan); 396 %SetInlineBuiltinFlag(MathTan);
397 } 397 }
398 398
399 SetUpMath(); 399 SetUpMath();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698