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

Side by Side Diff: src/cpu-profiler.h

Issue 632313002: Fix data race on CpuProfiler::running_ (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CPU_PROFILER_H_ 5 #ifndef V8_CPU_PROFILER_H_
6 #define V8_CPU_PROFILER_H_ 6 #define V8_CPU_PROFILER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
10 #include "src/base/platform/time.h" 10 #include "src/base/platform/time.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 class ProfilerEventsProcessor : public base::Thread { 125 class ProfilerEventsProcessor : public base::Thread {
126 public: 126 public:
127 ProfilerEventsProcessor(ProfileGenerator* generator, 127 ProfilerEventsProcessor(ProfileGenerator* generator,
128 Sampler* sampler, 128 Sampler* sampler,
129 base::TimeDelta period); 129 base::TimeDelta period);
130 virtual ~ProfilerEventsProcessor() {} 130 virtual ~ProfilerEventsProcessor() {}
131 131
132 // Thread control. 132 // Thread control.
133 virtual void Run(); 133 virtual void Run();
134 void StopSynchronously(); 134 void StopSynchronously();
135 INLINE(bool running()) { return running_; } 135 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); }
136 void Enqueue(const CodeEventsContainer& event); 136 void Enqueue(const CodeEventsContainer& event);
137 137
138 // Puts current stack into tick sample events buffer. 138 // Puts current stack into tick sample events buffer.
139 void AddCurrentStack(Isolate* isolate); 139 void AddCurrentStack(Isolate* isolate);
140 140
141 // Tick sample events are filled directly in the buffer of the circular 141 // Tick sample events are filled directly in the buffer of the circular
142 // queue (because the structure is of fixed width, but usually not all 142 // queue (because the structure is of fixed width, but usually not all
143 // stack frame entries are filled.) This method returns a pointer to the 143 // stack frame entries are filled.) This method returns a pointer to the
144 // next record of the buffer. 144 // next record of the buffer.
145 inline TickSample* StartTickSample(); 145 inline TickSample* StartTickSample();
(...skipping 10 matching lines...) Expand all
156 156
157 enum SampleProcessingResult { 157 enum SampleProcessingResult {
158 OneSampleProcessed, 158 OneSampleProcessed,
159 FoundSampleForNextCodeEvent, 159 FoundSampleForNextCodeEvent,
160 NoSamplesInQueue 160 NoSamplesInQueue
161 }; 161 };
162 SampleProcessingResult ProcessOneSample(); 162 SampleProcessingResult ProcessOneSample();
163 163
164 ProfileGenerator* generator_; 164 ProfileGenerator* generator_;
165 Sampler* sampler_; 165 Sampler* sampler_;
166 bool running_; 166 base::Atomic32 running_;
167 // Sampling period in microseconds. 167 // Sampling period in microseconds.
168 const base::TimeDelta period_; 168 const base::TimeDelta period_;
169 UnboundQueue<CodeEventsContainer> events_buffer_; 169 UnboundQueue<CodeEventsContainer> events_buffer_;
170 static const size_t kTickSampleBufferSize = 1 * MB; 170 static const size_t kTickSampleBufferSize = 1 * MB;
171 static const size_t kTickSampleQueueLength = 171 static const size_t kTickSampleQueueLength =
172 kTickSampleBufferSize / sizeof(TickSampleEventRecord); 172 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
173 SamplingCircularQueue<TickSampleEventRecord, 173 SamplingCircularQueue<TickSampleEventRecord,
174 kTickSampleQueueLength> ticks_buffer_; 174 kTickSampleQueueLength> ticks_buffer_;
175 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 175 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
176 unsigned last_code_event_id_; 176 unsigned last_code_event_id_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool saved_is_logging_; 263 bool saved_is_logging_;
264 bool is_profiling_; 264 bool is_profiling_;
265 265
266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
267 }; 267 };
268 268
269 } } // namespace v8::internal 269 } } // namespace v8::internal
270 270
271 271
272 #endif // V8_CPU_PROFILER_H_ 272 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698