Index: src/v8.cc |
=================================================================== |
--- src/v8.cc (revision 11005) |
+++ src/v8.cc (working copy) |
@@ -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::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 @@ |
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 { |
@@ -237,12 +239,7 @@ |
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(); |
@@ -266,6 +263,12 @@ |
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 |