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

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

Issue 1922303002: Create libsampler as V8 sampler library. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix TSAN failure Created 4 years, 7 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
« no previous file with comments | « src/log.cc ('k') | src/profiler/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_PROFILER_CPU_PROFILER_H_ 5 #ifndef V8_PROFILER_CPU_PROFILER_H_
6 #define V8_PROFILER_CPU_PROFILER_H_ 6 #define V8_PROFILER_CPU_PROFILER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
11 #include "src/base/platform/time.h" 11 #include "src/base/platform/time.h"
12 #include "src/compiler.h" 12 #include "src/compiler.h"
13 #include "src/libsampler/v8-sampler.h"
13 #include "src/locked-queue.h" 14 #include "src/locked-queue.h"
14 #include "src/profiler/circular-queue.h" 15 #include "src/profiler/circular-queue.h"
15 #include "src/profiler/sampler.h"
16 #include "src/profiler/tick-sample.h" 16 #include "src/profiler/tick-sample.h"
17 17
18 namespace v8 { 18 namespace v8 {
19 namespace internal { 19 namespace internal {
20 20
21 // Forward declarations. 21 // Forward declarations.
22 class CodeEntry; 22 class CodeEntry;
23 class CodeMap; 23 class CodeMap;
24 class CpuProfile; 24 class CpuProfile;
25 class CpuProfilesCollection; 25 class CpuProfilesCollection;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #undef DECLARE_TYPE 121 #undef DECLARE_TYPE
122 }; 122 };
123 }; 123 };
124 124
125 125
126 // This class implements both the profile events processor thread and 126 // This class implements both the profile events processor thread and
127 // methods called by event producers: VM and stack sampler threads. 127 // methods called by event producers: VM and stack sampler threads.
128 class ProfilerEventsProcessor : public base::Thread { 128 class ProfilerEventsProcessor : public base::Thread {
129 public: 129 public:
130 ProfilerEventsProcessor(ProfileGenerator* generator, 130 ProfilerEventsProcessor(ProfileGenerator* generator,
131 Sampler* sampler, 131 sampler::Sampler* sampler,
132 base::TimeDelta period); 132 base::TimeDelta period);
133 virtual ~ProfilerEventsProcessor(); 133 virtual ~ProfilerEventsProcessor();
134 134
135 // Thread control. 135 // Thread control.
136 virtual void Run(); 136 virtual void Run();
137 void StopSynchronously(); 137 void StopSynchronously();
138 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); } 138 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); }
139 void Enqueue(const CodeEventsContainer& event); 139 void Enqueue(const CodeEventsContainer& event);
140 140
141 // Puts current stack into tick sample events buffer. 141 // Puts current stack into tick sample events buffer.
(...skipping 17 matching lines...) Expand all
159 bool ProcessCodeEvent(); 159 bool ProcessCodeEvent();
160 160
161 enum SampleProcessingResult { 161 enum SampleProcessingResult {
162 OneSampleProcessed, 162 OneSampleProcessed,
163 FoundSampleForNextCodeEvent, 163 FoundSampleForNextCodeEvent,
164 NoSamplesInQueue 164 NoSamplesInQueue
165 }; 165 };
166 SampleProcessingResult ProcessOneSample(); 166 SampleProcessingResult ProcessOneSample();
167 167
168 ProfileGenerator* generator_; 168 ProfileGenerator* generator_;
169 Sampler* sampler_; 169 sampler::Sampler* sampler_;
170 base::Atomic32 running_; 170 base::Atomic32 running_;
171 const base::TimeDelta period_; // Samples & code events processing period. 171 const base::TimeDelta period_; // Samples & code events processing period.
172 LockedQueue<CodeEventsContainer> events_buffer_; 172 LockedQueue<CodeEventsContainer> events_buffer_;
173 static const size_t kTickSampleBufferSize = 1 * MB; 173 static const size_t kTickSampleBufferSize = 1 * MB;
174 static const size_t kTickSampleQueueLength = 174 static const size_t kTickSampleQueueLength =
175 kTickSampleBufferSize / sizeof(TickSampleEventRecord); 175 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
176 SamplingCircularQueue<TickSampleEventRecord, 176 SamplingCircularQueue<TickSampleEventRecord,
177 kTickSampleQueueLength> ticks_buffer_; 177 kTickSampleQueueLength> ticks_buffer_;
178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
179 base::AtomicNumber<unsigned> last_code_event_id_; 179 base::AtomicNumber<unsigned> last_code_event_id_;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 bool is_profiling_; 270 bool is_profiling_;
271 271
272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
273 }; 273 };
274 274
275 } // namespace internal 275 } // namespace internal
276 } // namespace v8 276 } // namespace v8
277 277
278 278
279 #endif // V8_PROFILER_CPU_PROFILER_H_ 279 #endif // V8_PROFILER_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/profiler/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698