Index: src/runtime/runtime-maths.cc |
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc |
index 4cb4f006ff380af45488f7ec9ae91d0d8c7ddc4c..75ed0f8e42ce5776cfbf0669c96f6246f4aa4ddc 100644 |
--- a/src/runtime/runtime-maths.cc |
+++ b/src/runtime/runtime-maths.cc |
@@ -38,6 +38,11 @@ RUNTIME_FUNCTION(Runtime_GenerateRandomNumbers) { |
state0 = double_to_uint64(cache->get_scalar(kState0Offset)); |
state1 = double_to_uint64(cache->get_scalar(kState1Offset)); |
} else { |
+ // If a fixed random seed was requested, reset it whenever a script asks for |
+ // random numbers for the first time in this context. This ensures the |
+ // script sees a consistent sequence. |
+ if (FLAG_random_seed != 0) |
+ isolate->random_number_generator()->SetSeed(FLAG_random_seed); |
Yang
2017/03/23 12:30:13
I wonder whether it would be easier to simply set
Sami
2017/03/23 17:00:27
Sorry, missed this comment earlier. Yeah, that wou
|
cache = Handle<FixedDoubleArray>::cast( |
isolate->factory()->NewFixedDoubleArray(kCacheSize, TENURED)); |
native_context->set_math_random_cache(*cache); |