v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::base::RandomNumberGenerator Class Referencefinal

#include <random-number-generator.h>

Collaboration diagram for v8::base::RandomNumberGenerator:

Public Types

using EntropySource = bool (*)(unsigned char* buffer, size_t buflen)
 
using result_type = unsigned
 

Public Member Functions

 RandomNumberGenerator ()
 
 RandomNumberGenerator (int64_t seed)
 
V8_INLINE int NextInt () V8_WARN_UNUSED_RESULT
 
int NextInt (int max) V8_WARN_UNUSED_RESULT
 
V8_INLINE bool NextBool () V8_WARN_UNUSED_RESULT
 
double NextDouble () V8_WARN_UNUSED_RESULT
 
int64_t NextInt64 () V8_WARN_UNUSED_RESULT
 
void NextBytes (void *buffer, size_t buflen)
 
std::vector< uint64_t > NextSample (uint64_t max, size_t n) V8_WARN_UNUSED_RESULT
 
std::vector< uint64_t > NextSampleSlow (uint64_t max, size_t n, const std::unordered_set< uint64_t > &excluded=std::unordered_set< uint64_t >{}) V8_WARN_UNUSED_RESULT
 
void SetSeed (int64_t seed)
 
int64_t initial_seed () const
 
result_type operator() ()
 

Static Public Member Functions

static void SetEntropySource (EntropySource entropy_source)
 
static double ToDouble (uint64_t state0)
 
static void XorShift128 (uint64_t *state0, uint64_t *state1)
 
static uint64_t MurmurHash3 (uint64_t)
 
static constexpr result_type min ()
 
static constexpr result_type max ()
 

Private Member Functions

int Next (int bits) V8_WARN_UNUSED_RESULT
 

Private Attributes

int64_t initial_seed_
 
uint64_t state0_
 
uint64_t state1_
 

Static Private Attributes

static const int64_t kMultiplier = 0x5'deec'e66d
 
static const int64_t kAddend = 0xb
 
static const int64_t kMask = 0xffff'ffff'ffff
 

Detailed Description

Definition at line 38 of file random-number-generator.h.

Member Typedef Documentation

◆ EntropySource

using v8::base::RandomNumberGenerator::EntropySource = bool (*)(unsigned char* buffer, size_t buflen)

Definition at line 42 of file random-number-generator.h.

◆ result_type

Definition at line 135 of file random-number-generator.h.

Constructor & Destructor Documentation

◆ RandomNumberGenerator() [1/2]

v8::base::RandomNumberGenerator::RandomNumberGenerator ( )

Definition at line 35 of file random-number-generator.cc.

Here is the call graph for this function:

◆ RandomNumberGenerator() [2/2]

v8::base::RandomNumberGenerator::RandomNumberGenerator ( int64_t seed)
inlineexplicit

Definition at line 46 of file random-number-generator.h.

Member Function Documentation

◆ initial_seed()

int64_t v8::base::RandomNumberGenerator::initial_seed ( ) const
inline

Definition at line 108 of file random-number-generator.h.

Here is the caller graph for this function:

◆ max()

static constexpr result_type v8::base::RandomNumberGenerator::max ( )
inlinestaticconstexpr

Definition at line 138 of file random-number-generator.h.

Here is the caller graph for this function:

◆ min()

static constexpr result_type v8::base::RandomNumberGenerator::min ( )
inlinestaticconstexpr

Definition at line 137 of file random-number-generator.h.

◆ MurmurHash3()

uint64_t v8::base::RandomNumberGenerator::MurmurHash3 ( uint64_t h)
static

Definition at line 228 of file random-number-generator.cc.

Here is the caller graph for this function:

◆ Next()

int v8::base::RandomNumberGenerator::Next ( int bits)
private

Definition at line 212 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextBool()

V8_INLINE bool v8::base::RandomNumberGenerator::NextBool ( )
inline

Definition at line 68 of file random-number-generator.h.

◆ NextBytes()

void v8::base::RandomNumberGenerator::NextBytes ( void * buffer,
size_t buflen )

Definition at line 126 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextDouble()

double v8::base::RandomNumberGenerator::NextDouble ( )

Definition at line 114 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextInt() [1/2]

V8_INLINE int v8::base::RandomNumberGenerator::NextInt ( )
inline

Definition at line 53 of file random-number-generator.h.

Here is the caller graph for this function:

◆ NextInt() [2/2]

int v8::base::RandomNumberGenerator::NextInt ( int max)

Definition at line 96 of file random-number-generator.cc.

Here is the call graph for this function:

◆ NextInt64()

int64_t v8::base::RandomNumberGenerator::NextInt64 ( )

Definition at line 120 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSample()

std::vector< uint64_t > v8::base::RandomNumberGenerator::NextSample ( uint64_t max,
size_t n )

Definition at line 144 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextSampleSlow()

std::vector< uint64_t > v8::base::RandomNumberGenerator::NextSampleSlow ( uint64_t max,
size_t n,
const std::unordered_set< uint64_t > & excluded = std::unordered_set<uint64_t>{} )

Definition at line 177 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator()()

result_type v8::base::RandomNumberGenerator::operator() ( )
inline

Definition at line 136 of file random-number-generator.h.

◆ SetEntropySource()

void v8::base::RandomNumberGenerator::SetEntropySource ( EntropySource entropy_source)
static

Definition at line 29 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSeed()

void v8::base::RandomNumberGenerator::SetSeed ( int64_t seed)

Definition at line 220 of file random-number-generator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToDouble()

static double v8::base::RandomNumberGenerator::ToDouble ( uint64_t state0)
inlinestatic

Definition at line 111 of file random-number-generator.h.

Here is the caller graph for this function:

◆ XorShift128()

static void v8::base::RandomNumberGenerator::XorShift128 ( uint64_t * state0,
uint64_t * state1 )
inlinestatic

Definition at line 121 of file random-number-generator.h.

Here is the caller graph for this function:

Member Data Documentation

◆ initial_seed_

int64_t v8::base::RandomNumberGenerator::initial_seed_
private

Definition at line 149 of file random-number-generator.h.

◆ kAddend

const int64_t v8::base::RandomNumberGenerator::kAddend = 0xb
staticprivate

Definition at line 144 of file random-number-generator.h.

◆ kMask

const int64_t v8::base::RandomNumberGenerator::kMask = 0xffff'ffff'ffff
staticprivate

Definition at line 145 of file random-number-generator.h.

◆ kMultiplier

const int64_t v8::base::RandomNumberGenerator::kMultiplier = 0x5'deec'e66d
staticprivate

Definition at line 143 of file random-number-generator.h.

◆ state0_

uint64_t v8::base::RandomNumberGenerator::state0_
private

Definition at line 150 of file random-number-generator.h.

◆ state1_

uint64_t v8::base::RandomNumberGenerator::state1_
private

Definition at line 151 of file random-number-generator.h.


The documentation for this class was generated from the following files: