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

Unified Diff: src/platform-cygwin.cc

Issue 9976003: Minimize uses of lazy initialization by adding explicit initialization functions. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Daniel's comments. Created 8 years, 8 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/log.cc ('k') | src/platform-freebsd.cc » ('j') | src/v8.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-cygwin.cc
diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc
index dd7253ba0651051df6fe351e18832c702fc34d8c..8b1e38197f299886b30c7ddcd54db3e31e3ade2d 100644
--- a/src/platform-cygwin.cc
+++ b/src/platform-cygwin.cc
@@ -62,22 +62,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();
}
uint64_t OS::CpuFeaturesImpliedByPlatform() {
@@ -634,8 +620,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());
@@ -646,7 +638,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_);
@@ -732,7 +724,7 @@ class SamplerThread : public Thread {
RuntimeProfilerRateLimiter rate_limiter_;
// Protects the process wide state below.
- static LazyMutex mutex_;
+ static Mutex* mutex_;
static SamplerThread* instance_;
private:
@@ -740,10 +732,23 @@ class SamplerThread : public Thread {
};
-LazyMutex SamplerThread::mutex_ = LAZY_MUTEX_INITIALIZER;
+Mutex* SamplerThread::mutex_ = NULL;
SamplerThread* SamplerThread::instance_ = 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();
+ SamplerThread::SetUp();
+}
+
+
Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate),
interval_(interval),
« no previous file with comments | « src/log.cc ('k') | src/platform-freebsd.cc » ('j') | src/v8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698