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

Unified Diff: src/log.cc

Issue 639763002: Make Profiler::tail_ atomic (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 1b350c4909478a2996d61755389217aafd0ab1a5..db1f3cf880e63f7a4794c39618770f81ea3b22cb 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -607,7 +607,7 @@ class Profiler: public base::Thread {
if (paused_)
return;
- if (Succ(head_) == tail_) {
+ if (Succ(head_) == static_cast<int>(base::NoBarrier_Load(&tail_))) {
overflow_ = true;
} else {
buffer_[head_] = *sample;
@@ -626,9 +626,10 @@ class Profiler: public base::Thread {
// Waits for a signal and removes profiling data.
bool Remove(TickSample* sample) {
buffer_semaphore_.Wait(); // Wait for an element.
- *sample = buffer_[tail_];
+ *sample = buffer_[base::NoBarrier_Load(&tail_)];
bool result = overflow_;
- tail_ = Succ(tail_);
+ base::NoBarrier_Store(&tail_, static_cast<base::Atomic32>(
+ Succ(base::NoBarrier_Load(&tail_))));
overflow_ = false;
return result;
}
@@ -642,7 +643,7 @@ class Profiler: public base::Thread {
static const int kBufferSize = 128;
TickSample buffer_[kBufferSize]; // Buffer storage.
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.
// Sempahore used for buffer synchronization.
base::Semaphore buffer_semaphore_;
@@ -699,12 +700,13 @@ Profiler::Profiler(Isolate* isolate)
: base::Thread(Options("v8:Profiler")),
isolate_(isolate),
head_(0),
- tail_(0),
overflow_(false),
buffer_semaphore_(0),
engaged_(false),
running_(false),
- paused_(false) {}
+ paused_(false) {
+ base::NoBarrier_Store(&tail_, 0);
+}
void Profiler::Engage() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698