Commit 0fae280e authored by jochen@chromium.org's avatar jochen@chromium.org

Make Profiler::running_ atomic.

It's used from multiple threads

BUG=none
R=yangguo@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/640773002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24480 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c09abc87
...@@ -652,7 +652,7 @@ class Profiler: public base::Thread { ...@@ -652,7 +652,7 @@ class Profiler: public base::Thread {
bool engaged_; bool engaged_;
// Tells whether worker thread should continue running. // Tells whether worker thread should continue running.
bool running_; base::Atomic32 running_;
// Tells whether we are currently recording tick samples. // Tells whether we are currently recording tick samples.
bool paused_; bool paused_;
...@@ -703,9 +703,9 @@ Profiler::Profiler(Isolate* isolate) ...@@ -703,9 +703,9 @@ Profiler::Profiler(Isolate* isolate)
overflow_(false), overflow_(false),
buffer_semaphore_(0), buffer_semaphore_(0),
engaged_(false), engaged_(false),
running_(false),
paused_(false) { paused_(false) {
base::NoBarrier_Store(&tail_, 0); base::NoBarrier_Store(&tail_, 0);
base::NoBarrier_Store(&running_, 0);
} }
...@@ -721,7 +721,7 @@ void Profiler::Engage() { ...@@ -721,7 +721,7 @@ void Profiler::Engage() {
} }
// Start thread processing the profiler buffer. // Start thread processing the profiler buffer.
running_ = true; base::NoBarrier_Store(&running_, 1);
Start(); Start();
// Register to get ticks. // Register to get ticks.
...@@ -741,7 +741,7 @@ void Profiler::Disengage() { ...@@ -741,7 +741,7 @@ void Profiler::Disengage() {
// Terminate the worker thread by setting running_ to false, // Terminate the worker thread by setting running_ to false,
// inserting a fake element in the queue and then wait for // inserting a fake element in the queue and then wait for
// the thread to terminate. // the thread to terminate.
running_ = false; base::NoBarrier_Store(&running_, 0);
TickSample sample; TickSample sample;
// Reset 'paused_' flag, otherwise semaphore may not be signalled. // Reset 'paused_' flag, otherwise semaphore may not be signalled.
resume(); resume();
...@@ -755,7 +755,7 @@ void Profiler::Disengage() { ...@@ -755,7 +755,7 @@ void Profiler::Disengage() {
void Profiler::Run() { void Profiler::Run() {
TickSample sample; TickSample sample;
bool overflow = Remove(&sample); bool overflow = Remove(&sample);
while (running_) { while (base::NoBarrier_Load(&running_)) {
LOG(isolate_, TickEvent(&sample, overflow)); LOG(isolate_, TickEvent(&sample, overflow));
overflow = Remove(&sample); overflow = Remove(&sample);
} }
......
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