Index: src/runtime/runtime-maths.cc |
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc |
index 504261679e448b79aa4b15d0b47fc8d838a10b59..cbf33a75d4c353aa98875caccd9bf9ce53549afb 100644 |
--- a/src/runtime/runtime-maths.cc |
+++ b/src/runtime/runtime-maths.cc |
@@ -6,6 +6,7 @@ |
#include "src/arguments.h" |
#include "src/assembler.h" |
+#include "src/base/utils/random-number-generator.h" |
#include "src/codegen.h" |
#include "src/third_party/fdlibm/fdlibm.h" |
@@ -244,5 +245,20 @@ RUNTIME_FUNCTION(Runtime_IsMinusZero) { |
HeapNumber* number = HeapNumber::cast(obj); |
return isolate->heap()->ToBoolean(IsMinusZero(number->value())); |
} |
+ |
+ |
+RUNTIME_FUNCTION(Runtime_InitializeRNG) { |
+ HandleScope scope(isolate); |
+ DCHECK(args.length() == 0); |
+ static const int kSize = 4; |
+ Handle<FixedArray> array = isolate->factory()->NewFixedArray(kSize); |
+ uint16_t seeds[kSize]; |
+ do { |
+ isolate->random_number_generator()->NextBytes(seeds, |
+ kSize * sizeof(*seeds)); |
+ } while (!(seeds[0] && seeds[1] && seeds[2] && seeds[3])); |
+ for (int i = 0; i < kSize; i++) array->set(i, Smi::FromInt(seeds[i])); |
+ return *isolate->factory()->NewJSArrayWithElements(array); |
+} |
} // namespace internal |
} // namespace v8 |