| Index: src/platform-freebsd.cc
|
| diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
|
| index 6a004ea7fa0fec3ddef51c680538ce01fa8614a6..6b1c987e2ff9ebadd7cb16e9fde4047fa6b26654 100644
|
| --- a/src/platform-freebsd.cc
|
| +++ b/src/platform-freebsd.cc
|
| @@ -80,22 +80,8 @@ double ceiling(double x) {
|
| static Mutex* limit_mutex = NULL;
|
|
|
|
|
| -void OS::SetUp() {
|
| - // Seed the random number generator.
|
| - // Convert the current time to a 64-bit integer first, before converting it
|
| - // to an unsigned. Going directly can cause an overflow and the seed to be
|
| - // set to all ones. The seed will be identical for different instances that
|
| - // call this setup code within the same millisecond.
|
| - uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
|
| - 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();
|
| }
|
|
|
|
|
| @@ -730,8 +716,14 @@ class SignalSender : public Thread {
|
| : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
|
| 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) {
|
| // Install a signal handler.
|
| @@ -751,7 +743,7 @@ class SignalSender : 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_);
|
| @@ -844,7 +836,7 @@ class SignalSender : public Thread {
|
| RuntimeProfilerRateLimiter rate_limiter_;
|
|
|
| // Protects the process wide state below.
|
| - static LazyMutex mutex_;
|
| + static Mutex* mutex_;
|
| static SignalSender* instance_;
|
| static bool signal_handler_installed_;
|
| static struct sigaction old_signal_handler_;
|
| @@ -853,12 +845,25 @@ class SignalSender : public Thread {
|
| DISALLOW_COPY_AND_ASSIGN(SignalSender);
|
| };
|
|
|
| -LazyMutex SignalSender::mutex_ = LAZY_MUTEX_INITIALIZER;
|
| +Mutex* SignalSender::mutex_ = NULL;
|
| SignalSender* SignalSender::instance_ = NULL;
|
| struct sigaction SignalSender::old_signal_handler_;
|
| bool SignalSender::signal_handler_installed_ = false;
|
|
|
|
|
| +void OS::SetUp() {
|
| + // Seed the random number generator.
|
| + // Convert the current time to a 64-bit integer first, before converting it
|
| + // to an unsigned. Going directly can cause an overflow and the seed to be
|
| + // set to all ones. The seed will be identical for different instances that
|
| + // call this setup code within the same millisecond.
|
| + uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
|
| + srandom(static_cast<unsigned int>(seed));
|
| + limit_mutex = CreateMutex();
|
| + SignalSender::SetUp();
|
| +}
|
| +
|
| +
|
| Sampler::Sampler(Isolate* isolate, int interval)
|
| : isolate_(isolate),
|
| interval_(interval),
|
|
|