// Copyright 2013 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_ #define V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_ #include <unordered_set> #include <vector> #include "src/base/base-export.h" #include "src/base/macros.h" namespace v8 { namespace base { // ----------------------------------------------------------------------------- // RandomNumberGenerator // This class is used to generate a stream of pseudo-random numbers. The class // uses a 64-bit seed, which is passed through MurmurHash3 to create two 64-bit // state values. This pair of state values is then used in xorshift128+. // The resulting stream of pseudo-random numbers has a period length of 2^128-1. // See Marsaglia: http://www.jstatsoft.org/v08/i14/paper // And Vigna: http://vigna.di.unimi.it/ftp/papers/xorshiftplus.pdf // NOTE: Any changes to the algorithm must be tested against TestU01. // Please find instructions for this in the internal repository. // If two instances of RandomNumberGenerator are created with the same seed, and // the same sequence of method calls is made for each, they will generate and // return identical sequences of numbers. // This class uses (probably) weak entropy by default, but it's sufficient, // because it is the responsibility of the embedder to install an entropy source // using v8::V8::SetEntropySource(), which provides reasonable entropy, see: // https://code.google.com/p/v8/issues/detail?id=2905 // This class is neither reentrant nor threadsafe. class V8_BASE_EXPORT RandomNumberGenerator final { … }; } // namespace base } // namespace v8 #endif // V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_