Index: src/v8.cc |
diff --git a/src/v8.cc b/src/v8.cc |
index 395401d91b2c575ccfe1ca009e403eb3d7b5cc6f..5af200348b4058e4c65075dc4d58102393f63fd9 100644 |
--- a/src/v8.cc |
+++ b/src/v8.cc |
@@ -155,6 +155,14 @@ void V8::TearDown() { |
} |
+static uint32_t random_seed() { |
+ if (FLAG_random_seed == 0) { |
+ return random(); |
+ } |
+ return FLAG_random_seed; |
+} |
+ |
+ |
uint32_t V8::Random() { |
// Random number generator using George Marsaglia's MWC algorithm. |
static uint32_t hi = 0; |
@@ -164,8 +172,8 @@ uint32_t V8::Random() { |
// should ever become zero again, or if random() returns zero, we |
// avoid getting stuck with zero bits in hi or lo by re-initializing |
// them on demand. |
- if (hi == 0) hi = random(); |
- if (lo == 0) lo = random(); |
+ if (hi == 0) hi = random_seed(); |
+ if (lo == 0) lo = random_seed(); |
// Mix the bits. |
hi = 36969 * (hi & 0xFFFF) + (hi >> 16); |