Valgrind cleanliness, part 6: Introduce OS::TearDown, cleaning up 2 mutexes.

Review URL: https://chromiumcodereview.appspot.com/10084003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11320 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f07b2133
...@@ -620,11 +620,8 @@ class SamplerThread : public Thread { ...@@ -620,11 +620,8 @@ class SamplerThread : public Thread {
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void AddActiveSampler(Sampler* sampler) { static void AddActiveSampler(Sampler* sampler) {
ScopedLock lock(mutex_); ScopedLock lock(mutex_);
...@@ -749,6 +746,12 @@ void OS::SetUp() { ...@@ -749,6 +746,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SamplerThread::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -716,11 +716,8 @@ class SignalSender : public Thread { ...@@ -716,11 +716,8 @@ class SignalSender : public Thread {
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void AddActiveSampler(Sampler* sampler) { static void AddActiveSampler(Sampler* sampler) {
ScopedLock lock(mutex_); ScopedLock lock(mutex_);
...@@ -864,6 +861,12 @@ void OS::SetUp() { ...@@ -864,6 +861,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SignalSender::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -1055,11 +1055,8 @@ class SignalSender : public Thread { ...@@ -1055,11 +1055,8 @@ class SignalSender : public Thread {
vm_tgid_(getpid()), vm_tgid_(getpid()),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void InstallSignalHandler() { static void InstallSignalHandler() {
struct sigaction sa; struct sigaction sa;
...@@ -1238,6 +1235,12 @@ void OS::SetUp() { ...@@ -1238,6 +1235,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SignalSender::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -743,11 +743,8 @@ class SamplerThread : public Thread { ...@@ -743,11 +743,8 @@ class SamplerThread : public Thread {
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void AddActiveSampler(Sampler* sampler) { static void AddActiveSampler(Sampler* sampler) {
ScopedLock lock(mutex_); ScopedLock lock(mutex_);
...@@ -881,6 +878,12 @@ void OS::SetUp() { ...@@ -881,6 +878,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SamplerThread::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -91,6 +91,11 @@ void OS::PostSetUp() { ...@@ -91,6 +91,11 @@ void OS::PostSetUp() {
} }
void OS::TearDown() {
UNIMPLEMENTED();
}
// Returns the accumulated user time for thread. // Returns the accumulated user time for thread.
int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
UNIMPLEMENTED(); UNIMPLEMENTED();
......
...@@ -793,11 +793,8 @@ class SignalSender : public Thread { ...@@ -793,11 +793,8 @@ class SignalSender : public Thread {
vm_tgid_(getpid()), vm_tgid_(getpid()),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void InstallSignalHandler() { static void InstallSignalHandler() {
struct sigaction sa; struct sigaction sa;
...@@ -948,6 +945,12 @@ void OS::SetUp() { ...@@ -948,6 +945,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SignalSender::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -712,11 +712,8 @@ class SignalSender : public Thread { ...@@ -712,11 +712,8 @@ class SignalSender : public Thread {
: Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void InstallSignalHandler() { static void InstallSignalHandler() {
struct sigaction sa; struct sigaction sa;
...@@ -870,6 +867,12 @@ void OS::SetUp() { ...@@ -870,6 +867,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SignalSender::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -1949,11 +1949,8 @@ class SamplerThread : public Thread { ...@@ -1949,11 +1949,8 @@ class SamplerThread : public Thread {
: Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
interval_(interval) {} interval_(interval) {}
static void SetUp() { static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
if (!mutex_) { static void TearDown() { delete mutex_; }
mutex_ = OS::CreateMutex();
}
}
static void AddActiveSampler(Sampler* sampler) { static void AddActiveSampler(Sampler* sampler) {
ScopedLock lock(mutex_); ScopedLock lock(mutex_);
...@@ -2078,6 +2075,12 @@ void OS::SetUp() { ...@@ -2078,6 +2075,12 @@ void OS::SetUp() {
} }
void OS::TearDown() {
SamplerThread::TearDown();
delete limit_mutex;
}
Sampler::Sampler(Isolate* isolate, int interval) Sampler::Sampler(Isolate* isolate, int interval)
: isolate_(isolate), : isolate_(isolate),
interval_(interval), interval_(interval),
......
...@@ -123,6 +123,9 @@ class OS { ...@@ -123,6 +123,9 @@ class OS {
// called after CPU initialization. // called after CPU initialization.
static void PostSetUp(); static void PostSetUp();
// Clean up platform-OS-related things. Called once at VM shutdown.
static void TearDown();
// Returns the accumulated user time for thread. This routine // Returns the accumulated user time for thread. This routine
// can be used for profiling. The implementation should // can be used for profiling. The implementation should
// strive for high-precision timer resolution, preferable // strive for high-precision timer resolution, preferable
......
...@@ -118,6 +118,8 @@ void V8::TearDown() { ...@@ -118,6 +118,8 @@ void V8::TearDown() {
delete call_completed_callbacks_; delete call_completed_callbacks_;
call_completed_callbacks_ = NULL; call_completed_callbacks_ = NULL;
OS::TearDown();
} }
...@@ -248,7 +250,6 @@ Object* V8::FillHeapNumberWithRandom(Object* heap_number, ...@@ -248,7 +250,6 @@ Object* V8::FillHeapNumberWithRandom(Object* heap_number,
} }
void V8::InitializeOncePerProcessImpl() { void V8::InitializeOncePerProcessImpl() {
// Set up the platform OS support.
OS::SetUp(); OS::SetUp();
use_crankshaft_ = FLAG_crankshaft; use_crankshaft_ = FLAG_crankshaft;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment