Index: src/platform-macos.cc |
diff --git a/src/platform-macos.cc b/src/platform-macos.cc |
index dbcd80e9f21222faab02df1aab68f3958f7b27f4..afcd80affff3812b0622e6735c118b2a811e1870 100644 |
--- a/src/platform-macos.cc |
+++ b/src/platform-macos.cc |
@@ -94,18 +94,8 @@ double ceiling(double x) { |
static Mutex* limit_mutex = NULL; |
-void OS::SetUp() { |
- // Seed the random number generator. We preserve microsecond resolution. |
- uint64_t seed = Ticks() ^ (getpid() << 16); |
- srandom(static_cast<unsigned int>(seed)); |
- limit_mutex = CreateMutex(); |
-} |
- |
- |
void OS::PostSetUp() { |
- // Math functions depend on CPU features therefore they are initialized after |
- // CPU. |
- MathSetup(); |
+ POSIXPostSetUp(); |
} |
@@ -753,8 +743,14 @@ class SamplerThread : public Thread { |
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), |
interval_(interval) {} |
+ static void SetUp() { |
+ if (!mutex_) { |
+ mutex_ = OS::CreateMutex(); |
+ } |
+ } |
+ |
static void AddActiveSampler(Sampler* sampler) { |
- ScopedLock lock(mutex_.Pointer()); |
+ ScopedLock lock(mutex_); |
SamplerRegistry::AddActiveSampler(sampler); |
if (instance_ == NULL) { |
instance_ = new SamplerThread(sampler->interval()); |
@@ -765,7 +761,7 @@ class SamplerThread : public Thread { |
} |
static void RemoveActiveSampler(Sampler* sampler) { |
- ScopedLock lock(mutex_.Pointer()); |
+ ScopedLock lock(mutex_); |
SamplerRegistry::RemoveActiveSampler(sampler); |
if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { |
RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); |
@@ -862,7 +858,7 @@ class SamplerThread : public Thread { |
RuntimeProfilerRateLimiter rate_limiter_; |
// Protects the process wide state below. |
- static LazyMutex mutex_; |
+ static Mutex* mutex_; |
static SamplerThread* instance_; |
private: |
@@ -872,10 +868,19 @@ class SamplerThread : public Thread { |
#undef REGISTER_FIELD |
-LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER; |
+Mutex* SamplerThread::mutex_ = NULL; |
SamplerThread* SamplerThread::instance_ = NULL; |
+void OS::SetUp() { |
+ // Seed the random number generator. We preserve microsecond resolution. |
+ uint64_t seed = Ticks() ^ (getpid() << 16); |
+ srandom(static_cast<unsigned int>(seed)); |
+ limit_mutex = CreateMutex(); |
+ SamplerThread::SetUp(); |
+} |
+ |
+ |
Sampler::Sampler(Isolate* isolate, int interval) |
: isolate_(isolate), |
interval_(interval), |