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

Side by Side Diff: src/math.js

Issue 68723002: Implement Math.random() purely in JavaScript. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments only 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 | « src/ia32/lithium-ia32.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 return r; 162 return r;
163 } 163 }
164 164
165 // ECMA 262 - 15.8.2.13 165 // ECMA 262 - 15.8.2.13
166 function MathPow(x, y) { 166 function MathPow(x, y) {
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 function MathRandom() { 172 function MathRandom() {
172 return %_RandomHeapNumber(); 173 var r0 = (MathImul(18273, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
174 rngstate[0] = r0;
175 var r1 = (MathImul(36969, rngstate[1] & 0xFFFF) + (rngstate[1] >>> 16)) | 0;
176 rngstate[1] = r1;
177 var x = ((r0 << 14) + (r1 & 0x3FFFF)) | 0;
178 // Division by 0x100000000 through multiplication by reciprocal.
179 return (x < 0 ? (x + 0x100000000) : x) * 2.3283064365386962890625e-10;
173 } 180 }
174 181
175 // ECMA 262 - 15.8.2.15 182 // ECMA 262 - 15.8.2.15
176 function MathRound(x) { 183 function MathRound(x) {
177 return %RoundNumber(TO_NUMBER_INLINE(x)); 184 return %RoundNumber(TO_NUMBER_INLINE(x));
178 } 185 }
179 186
180 // ECMA 262 - 15.8.2.16 187 // ECMA 262 - 15.8.2.16
181 function MathSin(x) { 188 function MathSin(x) {
182 return MathSinImpl(x); 189 return MathSinImpl(x);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 "min", MathMin, 368 "min", MathMin,
362 "imul", MathImul 369 "imul", MathImul
363 )); 370 ));
364 371
365 %SetInlineBuiltinFlag(MathSin); 372 %SetInlineBuiltinFlag(MathSin);
366 %SetInlineBuiltinFlag(MathCos); 373 %SetInlineBuiltinFlag(MathCos);
367 %SetInlineBuiltinFlag(MathTan); 374 %SetInlineBuiltinFlag(MathTan);
368 } 375 }
369 376
370 SetUpMath(); 377 SetUpMath();
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698