Commit d75baead authored by yangguo's avatar yangguo Committed by Commit bot

[rng] improve RNG seed.

Prior to this change, both 0 and 1 as RNG seed would result in the same
internal state. state0 and state1 cannot both be zero, but murmur hash
maps 0 back to 0.

R=cbruni@chromium.org
BUG=v8:5069

Review-Url: https://codereview.chromium.org/2040953002
Cr-Commit-Position: refs/heads/master@{#36757}
parent 95f210d5
......@@ -124,10 +124,10 @@ int RandomNumberGenerator::Next(int bits) {
void RandomNumberGenerator::SetSeed(int64_t seed) {
if (seed == 0) seed = 1;
initial_seed_ = seed;
state0_ = MurmurHash3(bit_cast<uint64_t>(seed));
state1_ = MurmurHash3(state0_);
state1_ = MurmurHash3(~state0_);
CHECK(state0_ != 0 || state1_ != 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment