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

Issue 23548024: Introduce a RandonNumberGenerator class. Refactor the random/private_random uses in Isolate/Context. (Closed)

Created:
7 years, 3 months ago by Benedikt Meurer
Modified:
7 years, 3 months ago
Reviewers:
Michael Starzinger
CC:
v8-dev
Visibility:
Public.

Description

Introduce a RandonNumberGenerator class. Refactor the random/private_random uses in Isolate/Context. The RandomNumberGenerator is a pseudorandom number generator with 48-bit state. It is properly seeded using either (1) the --random-seed if specified, or (2) the entropy_source function if configured, or (3) /dev/urandom if available, or (4) falls back to Time and TimeTicks based seeding. Each Isolate now contains a RandomNumberGenerator, which replaces the previous private_random_seed. Every native context still has its own random_seed. But this random seed is now properly initialized during bootstrapping, instead of on-demand initialization. This will allow us to cleanup and speedup the HRandom implementation quite a lot (this is delayed for a followup CL)! Also stop messing with the system rand()/random(), which should not be done from a library anyway! We probably re-seeded the libc rand()/random() after the application (i.e. Chrome) already seeded it (with better entropy than what we used). Another followup CL will replace the use of the per-isolate random number generator for the address randomization and thereby get rid of the Isolate::UncheckedCurrent() usage in the platform code. TEST=cctest/test-random-number-generator,cctest/test-random R=mstarzinger@chromium.org Committed: https://code.google.com/p/v8/source/detail?r=16612

Patch Set 1 #

Patch Set 2 : Initialize random_number_generator of Isolate lazily. #

Total comments: 23

Patch Set 3 : REBASE #

Patch Set 4 : Addressed comments. #

Total comments: 10

Patch Set 5 : Addressed second round of comments. #

Patch Set 6 : REBASE #

Unified diffs Side-by-side diffs Delta from patch set Stats (+390 lines, -213 lines) Patch
M src/api.cc View 1 2 3 4 5 2 chunks +3 lines, -2 lines 0 comments Download
M src/assembler.cc View 1 2 chunks +2 lines, -2 lines 0 comments Download
M src/bootstrapper.cc View 1 2 3 4 2 chunks +11 lines, -7 lines 0 comments Download
M src/flags.h View 1 chunk +3 lines, -0 lines 0 comments Download
M src/heap.cc View 1 2 3 4 chunks +5 lines, -3 lines 0 comments Download
M src/isolate.h View 1 2 3 4 5 3 chunks +4 lines, -0 lines 0 comments Download
M src/isolate.cc View 1 4 chunks +8 lines, -1 line 0 comments Download
M src/isolate-inl.h View 1 2 chunks +9 lines, -2 lines 0 comments Download
M src/objects.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M src/platform.h View 2 chunks +0 lines, -8 lines 0 comments Download
M src/platform-cygwin.cc View 1 2 2 chunks +3 lines, -14 lines 0 comments Download
M src/platform-freebsd.cc View 1 chunk +0 lines, -12 lines 0 comments Download
M src/platform-linux.cc View 1 chunk +0 lines, -8 lines 0 comments Download
M src/platform-macos.cc View 1 chunk +0 lines, -8 lines 0 comments Download
M src/platform-openbsd.cc View 1 chunk +0 lines, -8 lines 0 comments Download
M src/platform-posix.cc View 1 2 2 chunks +3 lines, -5 lines 0 comments Download
M src/platform-solaris.cc View 1 chunk +0 lines, -12 lines 0 comments Download
M src/platform-win32.cc View 1 2 4 chunks +4 lines, -20 lines 0 comments Download
M src/platform/time.h View 1 2 3 2 chunks +18 lines, -0 lines 0 comments Download
A src/utils/random-number-generator.h View 1 chunk +106 lines, -0 lines 0 comments Download
A src/utils/random-number-generator.cc View 1 chunk +136 lines, -0 lines 0 comments Download
M src/v8.h View 1 chunk +0 lines, -5 lines 0 comments Download
M src/v8.cc View 1 2 3 4 4 chunks +10 lines, -47 lines 0 comments Download
M test/cctest/cctest.gyp View 1 chunk +1 line, -0 lines 0 comments Download
M test/cctest/test-assembler-x64.cc View 7 chunks +0 lines, -7 lines 0 comments Download
M test/cctest/test-platform-linux.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M test/cctest/test-platform-win32.cc View 2 chunks +0 lines, -2 lines 0 comments Download
M test/cctest/test-random.cc View 1 chunk +1 line, -10 lines 0 comments Download
A + test/cctest/test-random-number-generator.cc View 1 chunk +52 lines, -15 lines 0 comments Download
M test/cctest/test-spaces.cc View 4 chunks +0 lines, -4 lines 0 comments Download
M test/cctest/test-strings.cc View 1 2 3 chunks +4 lines, -4 lines 0 comments Download
M test/cctest/test-strtod.cc View 3 chunks +4 lines, -3 lines 0 comments Download
M test/cctest/test-utils.cc View 1 chunk +0 lines, -1 line 0 comments Download
M tools/gyp/v8.gyp View 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Benedikt Meurer
Hey Michi, Here's the random cleanup. PTAL -- Benedikt
7 years, 3 months ago (2013-09-09 14:16:09 UTC) #1
Michael Starzinger
https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc#newcode1320 src/bootstrapper.cc:1320: Handle<ByteArray> random_seed(factory->NewByteArray(kRandomStateSize)); nit: Use assignment instead of copy constructor. ...
7 years, 3 months ago (2013-09-09 17:11:25 UTC) #2
Benedikt Meurer
PTAL https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc#newcode1320 src/bootstrapper.cc:1320: Handle<ByteArray> random_seed(factory->NewByteArray(kRandomStateSize)); On 2013/09/09 17:11:25, Michael Starzinger wrote: ...
7 years, 3 months ago (2013-09-10 06:08:07 UTC) #3
Michael Starzinger
LGTM (if comment in bootstrapper.cc is addressed). https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc#newcode2410 src/bootstrapper.cc:2410: // using ...
7 years, 3 months ago (2013-09-10 08:43:31 UTC) #4
Benedikt Meurer
https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc File src/bootstrapper.cc (right): https://codereview.chromium.org/23548024/diff/4001/src/bootstrapper.cc#newcode2410 src/bootstrapper.cc:2410: // using the per-isolate random number generator. On 2013/09/10 ...
7 years, 3 months ago (2013-09-10 10:52:13 UTC) #5
Benedikt Meurer
7 years, 3 months ago (2013-09-10 11:14:28 UTC) #6
Message was sent while issue was closed.
Committed patchset #6 manually as r16612 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698