Index: src/v8.cc |
diff --git a/src/v8.cc b/src/v8.cc |
index 003c75ce0b36b7567113cb0b3c1c191b3c36c24b..5c2a0e93da7de4f09eef4803eeb942bfea0bbff9 100644 |
--- a/src/v8.cc |
+++ b/src/v8.cc |
@@ -36,6 +36,8 @@ |
#include "hydrogen.h" |
#include "lithium-allocator.h" |
#include "log.h" |
+#include "once.h" |
+#include "platform.h" |
#include "runtime-profiler.h" |
#include "serialize.h" |
#include "store-buffer.h" |
@@ -43,8 +45,7 @@ |
namespace v8 { |
namespace internal { |
-static Mutex* init_once_mutex = OS::CreateMutex(); |
-static bool init_once_called = false; |
+V8_DECLARE_ONCE(init_once); |
bool V8::is_running_ = false; |
bool V8::has_been_set_up_ = false; |
@@ -53,7 +54,8 @@ bool V8::has_fatal_error_ = false; |
bool V8::use_crankshaft_ = true; |
List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; |
-static Mutex* entropy_mutex = OS::CreateMutex(); |
+static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; |
+ |
static EntropySource entropy_source; |
@@ -117,7 +119,7 @@ static void seed_random(uint32_t* state) { |
state[i] = FLAG_random_seed; |
} else if (entropy_source != NULL) { |
uint32_t val; |
- ScopedLock lock(entropy_mutex); |
+ ScopedLock lock(entropy_mutex.Pointer()); |
entropy_source(reinterpret_cast<unsigned char*>(&val), sizeof(uint32_t)); |
state[i] = val; |
} else { |
@@ -239,12 +241,7 @@ Object* V8::FillHeapNumberWithRandom(Object* heap_number, |
return heap_number; |
} |
- |
-void V8::InitializeOncePerProcess() { |
- ScopedLock lock(init_once_mutex); |
- if (init_once_called) return; |
- init_once_called = true; |
- |
+void V8::InitializeOncePerProcessImpl() { |
// Set up the platform OS support. |
OS::SetUp(); |
@@ -268,6 +265,12 @@ void V8::InitializeOncePerProcess() { |
FLAG_gc_global = true; |
FLAG_max_new_space_size = (1 << (kPageSizeBits - 10)) * 2; |
} |
+ |
+ LOperand::SetUpCaches(); |
+} |
+ |
+void V8::InitializeOncePerProcess() { |
+ CallOnce(&init_once, &InitializeOncePerProcessImpl); |
} |
} } // namespace v8::internal |