Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: src/runtime/runtime-maths.cc

Issue 2760393002: Enable deterministic random number generation (Closed)
Patch Set: Reset in Runtime_GenerateRandomNumbers instead Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698