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

Issue 126113: Change the implementation of Math.random to use George... (Closed)

Created:
11 years, 6 months ago by Kasper Lund
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Change the implementation of Math.random to use George Marsaglia's multiply-with-carry instead of mixing the bits obtained from calling the system random() twice. This seems to be a bit faster and gives a better distribution than the system random() in particular on Windows. Committed: http://code.google.com/p/v8/source/detail?r=2159

Patch Set 1 #

Patch Set 2 : '' #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+143 lines, -46 lines) Patch
M src/api.cc View 1 chunk +3 lines, -1 line 0 comments Download
M src/arm/codegen-arm.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M src/arm/codegen-arm.cc View 1 chunk +9 lines, -0 lines 0 comments Download
M src/assembler.h View 1 chunk +1 line, -1 line 0 comments Download
M src/assembler.cc View 1 chunk +5 lines, -0 lines 0 comments Download
M src/codegen.cc View 1 chunk +2 lines, -1 line 0 comments Download
M src/ia32/codegen-ia32.h View 1 chunk +3 lines, -0 lines 0 comments Download
M src/ia32/codegen-ia32.cc View 1 chunk +9 lines, -0 lines 0 comments Download
M src/math.js View 2 chunks +72 lines, -20 lines 0 comments Download
M src/runtime.h View 1 chunk +0 lines, -1 line 0 comments Download
M src/runtime.cc View 1 chunk +0 lines, -18 lines 0 comments Download
M src/serialize.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M src/v8.h View 1 2 chunks +9 lines, -4 lines 1 comment Download
M src/v8.cc View 1 chunk +23 lines, -0 lines 1 comment Download

Messages

Total messages: 3 (0 generated)
Kasper Lund
Ready for initial review.
11 years, 6 months ago (2009-06-15 07:15:17 UTC) #1
Mads Ager (chromium)
LGTM http://codereview.chromium.org/126113/diff/39/43 File src/v8.h (right): http://codereview.chromium.org/126113/diff/39/43#newcode98 Line 98: static uint32_t Random(); Could these be in ...
11 years, 6 months ago (2009-06-15 07:22:56 UTC) #2
Dean McNamee
11 years, 6 months ago (2009-06-15 07:39:25 UTC) #3
Hey Kasper,

This is great, I had talked to Ivan once about it before.  It's good that we
avoid system random for a few reasons, including thread safety / lock holding /
etc.


I know nothing of the implementation though, I would have gone with mersenne
twister since it is what everyone else uses (python, ruby, etc)

http://codereview.chromium.org/126113/diff/39/48
File src/v8.cc (right):

http://codereview.chromium.org/126113/diff/39/48#newcode145
Line 145: static uint32_t lo = 0;
why not just static uint32_t hi = random() ?

Powered by Google App Engine
This is Rietveld 408576698