24 void RandomNumberGenerator::SetEntropySource(
EntropySource source) {
30 RandomNumberGenerator::RandomNumberGenerator() {
43 #if V8_OS_CYGWIN || V8_OS_WIN
46 unsigned first_half, second_half;
47 errno_t result = rand_s(&first_half);
49 result = rand_s(&second_half);
51 SetSeed((
static_cast<int64_t
>(first_half) << 32) + second_half);
54 FILE*
fp = fopen(
"/dev/urandom",
"rb");
57 size_t n = fread(&seed,
sizeof(seed), 1,
fp);
73 int64_t seed = Time::NowFromSystemTime().ToInternalValue() << 24;
74 seed ^= TimeTicks::HighResolutionNow().ToInternalValue() << 16;
75 seed ^= TimeTicks::Now().ToInternalValue() << 8;
81 int RandomNumberGenerator::NextInt(
int max) {
86 return static_cast<int>((max *
static_cast<int64_t
>(Next(31))) >> 31);
92 if (rnd - val + (max - 1) >= 0) {
99 double RandomNumberGenerator::NextDouble() {
100 return ((
static_cast<int64_t
>(Next(26)) << 27) + Next(27)) /
101 static_cast<double>(
static_cast<int64_t
>(1) << 53);
105 void RandomNumberGenerator::NextBytes(
void* buffer,
size_t buflen) {
106 for (
size_t n = 0; n < buflen; ++n) {
107 static_cast<uint8_t*
>(buffer)[n] =
static_cast<uint8_t
>(Next(8));
112 int RandomNumberGenerator::Next(
int bits) {
117 uint64_t product =
static_cast<uint64_t
>(seed_) * kMultiplier;
121 int64_t seed =
static_cast<int64_t
>((product + kAddend) & kMask);
123 return static_cast<int>(seed >> (48 - bits));
127 void RandomNumberGenerator::SetSeed(int64_t seed) {
128 initial_seed_ = seed;
129 seed_ = (seed ^ kMultiplier) & kMask;
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_GE(v1, v2)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
#define IS_POWER_OF_TWO(x)
#define LAZY_MUTEX_INITIALIZER
static LazyMutex entropy_mutex
static RandomNumberGenerator::EntropySource entropy_source
Debugger support for the V8 JavaScript engine.
bool(* EntropySource)(unsigned char *buffer, size_t length)
EntropySource is used as a callback function when v8 needs a source of entropy.