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

Unified Diff: src/v8.cc

Issue 7535004: Merge bleeding edge up to 8774 into the GC branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 5 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 | « src/v8.h ('k') | src/v8globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8.cc
===================================================================
--- src/v8.cc (revision 8778)
+++ src/v8.cc (working copy)
@@ -51,7 +51,10 @@
bool V8::has_fatal_error_ = false;
bool V8::use_crankshaft_ = true;
+static Mutex* entropy_mutex = OS::CreateMutex();
+static EntropySource entropy_source;
+
bool V8::Initialize(Deserializer* des) {
InitializeOncePerProcess();
@@ -103,8 +106,14 @@
static void seed_random(uint32_t* state) {
for (int i = 0; i < 2; ++i) {
- state[i] = FLAG_random_seed;
- while (state[i] == 0) {
+ if (FLAG_random_seed != 0) {
+ state[i] = FLAG_random_seed;
+ } else if (entropy_source != NULL) {
+ uint32_t val;
+ ScopedLock lock(entropy_mutex);
+ entropy_source(reinterpret_cast<unsigned char*>(&val), sizeof(uint32_t));
+ state[i] = val;
+ } else {
state[i] = random();
}
}
@@ -125,6 +134,11 @@
}
+void V8::SetEntropySource(EntropySource source) {
+ entropy_source = source;
+}
+
+
// Used by JavaScript APIs
uint32_t V8::Random(Isolate* isolate) {
ASSERT(isolate == Isolate::Current());
« no previous file with comments | « src/v8.h ('k') | src/v8globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698