Commit 76441ed5 authored by jochen@chromium.org's avatar jochen@chromium.org

Make Profiler::tail_ atomic

it's used on several threads

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

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24465 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5b463207
...@@ -607,7 +607,7 @@ class Profiler: public base::Thread { ...@@ -607,7 +607,7 @@ class Profiler: public base::Thread {
if (paused_) if (paused_)
return; return;
if (Succ(head_) == tail_) { if (Succ(head_) == static_cast<int>(base::NoBarrier_Load(&tail_))) {
overflow_ = true; overflow_ = true;
} else { } else {
buffer_[head_] = *sample; buffer_[head_] = *sample;
...@@ -626,9 +626,10 @@ class Profiler: public base::Thread { ...@@ -626,9 +626,10 @@ class Profiler: public base::Thread {
// Waits for a signal and removes profiling data. // Waits for a signal and removes profiling data.
bool Remove(TickSample* sample) { bool Remove(TickSample* sample) {
buffer_semaphore_.Wait(); // Wait for an element. buffer_semaphore_.Wait(); // Wait for an element.
*sample = buffer_[tail_]; *sample = buffer_[base::NoBarrier_Load(&tail_)];
bool result = overflow_; bool result = overflow_;
tail_ = Succ(tail_); base::NoBarrier_Store(&tail_, static_cast<base::Atomic32>(
Succ(base::NoBarrier_Load(&tail_))));
overflow_ = false; overflow_ = false;
return result; return result;
} }
...@@ -642,7 +643,7 @@ class Profiler: public base::Thread { ...@@ -642,7 +643,7 @@ class Profiler: public base::Thread {
static const int kBufferSize = 128; static const int kBufferSize = 128;
TickSample buffer_[kBufferSize]; // Buffer storage. TickSample buffer_[kBufferSize]; // Buffer storage.
int head_; // Index to the buffer head. int head_; // Index to the buffer head.
int tail_; // Index to the buffer tail. base::Atomic32 tail_; // Index to the buffer tail.
bool overflow_; // Tell whether a buffer overflow has occurred. bool overflow_; // Tell whether a buffer overflow has occurred.
// Sempahore used for buffer synchronization. // Sempahore used for buffer synchronization.
base::Semaphore buffer_semaphore_; base::Semaphore buffer_semaphore_;
...@@ -699,12 +700,13 @@ Profiler::Profiler(Isolate* isolate) ...@@ -699,12 +700,13 @@ Profiler::Profiler(Isolate* isolate)
: base::Thread(Options("v8:Profiler")), : base::Thread(Options("v8:Profiler")),
isolate_(isolate), isolate_(isolate),
head_(0), head_(0),
tail_(0),
overflow_(false), overflow_(false),
buffer_semaphore_(0), buffer_semaphore_(0),
engaged_(false), engaged_(false),
running_(false), running_(false),
paused_(false) {} paused_(false) {
base::NoBarrier_Store(&tail_, 0);
}
void Profiler::Engage() { void Profiler::Engage() {
......
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