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

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

Issue 1708573003: [WIP]Create a V8 sampler library and tracing controller. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/atomic-utils.h" 9 #include "src/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/locked-queue.h" 13 #include "src/locked-queue.h"
14 #include "src/profiler/circular-queue.h" 14 #include "src/profiler/circular-queue.h"
15 #include "src/profiler/sampler.h" 15 #include "src/profiler/sampler.h"
16 16
17 namespace v8 { 17 namespace v8 {
18
19 class V8Sampler;
20
18 namespace internal { 21 namespace internal {
19 22
20 // Forward declarations. 23 // Forward declarations.
21 class CodeEntry; 24 class CodeEntry;
22 class CodeMap; 25 class CodeMap;
23 class CompilationInfo; 26 class CompilationInfo;
24 class CpuProfile; 27 class CpuProfile;
25 class CpuProfilesCollection; 28 class CpuProfilesCollection;
26 class ProfileGenerator; 29 class ProfileGenerator;
27 30
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #undef DECLARE_TYPE 124 #undef DECLARE_TYPE
122 }; 125 };
123 }; 126 };
124 127
125 128
126 // This class implements both the profile events processor thread and 129 // This class implements both the profile events processor thread and
127 // methods called by event producers: VM and stack sampler threads. 130 // methods called by event producers: VM and stack sampler threads.
128 class ProfilerEventsProcessor : public base::Thread { 131 class ProfilerEventsProcessor : public base::Thread {
129 public: 132 public:
130 ProfilerEventsProcessor(ProfileGenerator* generator, 133 ProfilerEventsProcessor(ProfileGenerator* generator,
131 Sampler* sampler, 134 V8Sampler* sampler,
132 base::TimeDelta period); 135 base::TimeDelta period);
133 virtual ~ProfilerEventsProcessor(); 136 virtual ~ProfilerEventsProcessor();
134 137
135 // Thread control. 138 // Thread control.
136 virtual void Run(); 139 virtual void Run();
137 void StopSynchronously(); 140 void StopSynchronously();
138 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); } 141 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); }
139 void Enqueue(const CodeEventsContainer& event); 142 void Enqueue(const CodeEventsContainer& event);
140 143
141 // Puts current stack into tick sample events buffer. 144 // Puts current stack into tick sample events buffer.
(...skipping 17 matching lines...) Expand all
159 bool ProcessCodeEvent(); 162 bool ProcessCodeEvent();
160 163
161 enum SampleProcessingResult { 164 enum SampleProcessingResult {
162 OneSampleProcessed, 165 OneSampleProcessed,
163 FoundSampleForNextCodeEvent, 166 FoundSampleForNextCodeEvent,
164 NoSamplesInQueue 167 NoSamplesInQueue
165 }; 168 };
166 SampleProcessingResult ProcessOneSample(); 169 SampleProcessingResult ProcessOneSample();
167 170
168 ProfileGenerator* generator_; 171 ProfileGenerator* generator_;
169 Sampler* sampler_; 172 V8Sampler* sampler_;
170 base::Atomic32 running_; 173 base::Atomic32 running_;
171 const base::TimeDelta period_; // Samples & code events processing period. 174 const base::TimeDelta period_; // Samples & code events processing period.
172 LockedQueue<CodeEventsContainer> events_buffer_; 175 LockedQueue<CodeEventsContainer> events_buffer_;
173 static const size_t kTickSampleBufferSize = 1 * MB; 176 static const size_t kTickSampleBufferSize = 1 * MB;
174 static const size_t kTickSampleQueueLength = 177 static const size_t kTickSampleQueueLength =
175 kTickSampleBufferSize / sizeof(TickSampleEventRecord); 178 kTickSampleBufferSize / sizeof(TickSampleEventRecord);
176 SamplingCircularQueue<TickSampleEventRecord, 179 SamplingCircularQueue<TickSampleEventRecord,
177 kTickSampleQueueLength> ticks_buffer_; 180 kTickSampleQueueLength> ticks_buffer_;
178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 181 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
179 AtomicNumber<unsigned> last_code_event_id_; 182 AtomicNumber<unsigned> last_code_event_id_;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 bool is_profiling_; 272 bool is_profiling_;
270 273
271 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 274 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
272 }; 275 };
273 276
274 } // namespace internal 277 } // namespace internal
275 } // namespace v8 278 } // namespace v8
276 279
277 280
278 #endif // V8_PROFILER_CPU_PROFILER_H_ 281 #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