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

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

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 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
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/circular-queue.h" 11 #include "src/circular-queue.h"
11 #include "src/platform/time.h"
12 #include "src/sampler.h" 12 #include "src/sampler.h"
13 #include "src/unbound-queue.h" 13 #include "src/unbound-queue.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 // Forward declarations. 18 // Forward declarations.
19 class CodeEntry; 19 class CodeEntry;
20 class CodeMap; 20 class CodeMap;
21 class CompilationInfo; 21 class CompilationInfo;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 CodeEventRecord generic; 115 CodeEventRecord generic;
116 #define DECLARE_CLASS(ignore, type) type type##_; 116 #define DECLARE_CLASS(ignore, type) type type##_;
117 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) 117 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
118 #undef DECLARE_TYPE 118 #undef DECLARE_TYPE
119 }; 119 };
120 }; 120 };
121 121
122 122
123 // This class implements both the profile events processor thread and 123 // This class implements both the profile events processor thread and
124 // methods called by event producers: VM and stack sampler threads. 124 // methods called by event producers: VM and stack sampler threads.
125 class ProfilerEventsProcessor : public 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 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 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);
(...skipping 18 matching lines...) Expand all
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 bool running_;
167 // Sampling period in microseconds. 167 // Sampling period in microseconds.
168 const 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_;
177 unsigned last_processed_code_event_id_; 177 unsigned last_processed_code_event_id_;
178 }; 178 };
(...skipping 14 matching lines...) Expand all
193 public: 193 public:
194 explicit CpuProfiler(Isolate* isolate); 194 explicit CpuProfiler(Isolate* isolate);
195 195
196 CpuProfiler(Isolate* isolate, 196 CpuProfiler(Isolate* isolate,
197 CpuProfilesCollection* test_collection, 197 CpuProfilesCollection* test_collection,
198 ProfileGenerator* test_generator, 198 ProfileGenerator* test_generator,
199 ProfilerEventsProcessor* test_processor); 199 ProfilerEventsProcessor* test_processor);
200 200
201 virtual ~CpuProfiler(); 201 virtual ~CpuProfiler();
202 202
203 void set_sampling_interval(TimeDelta value); 203 void set_sampling_interval(base::TimeDelta value);
204 void StartProfiling(const char* title, bool record_samples = false); 204 void StartProfiling(const char* title, bool record_samples = false);
205 void StartProfiling(String* title, bool record_samples); 205 void StartProfiling(String* title, bool record_samples);
206 CpuProfile* StopProfiling(const char* title); 206 CpuProfile* StopProfiling(const char* title);
207 CpuProfile* StopProfiling(String* title); 207 CpuProfile* StopProfiling(String* title);
208 int GetProfilesCount(); 208 int GetProfilesCount();
209 CpuProfile* GetProfile(int index); 209 CpuProfile* GetProfile(int index);
210 void DeleteAllProfiles(); 210 void DeleteAllProfiles();
211 void DeleteProfile(CpuProfile* profile); 211 void DeleteProfile(CpuProfile* profile);
212 212
213 // Invoked from stack sampler (thread or signal handler.) 213 // Invoked from stack sampler (thread or signal handler.)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 Isolate* isolate() const { return isolate_; } 252 Isolate* isolate() const { return isolate_; }
253 253
254 private: 254 private:
255 void StartProcessorIfNotStarted(); 255 void StartProcessorIfNotStarted();
256 void StopProcessorIfLastProfile(const char* title); 256 void StopProcessorIfLastProfile(const char* title);
257 void StopProcessor(); 257 void StopProcessor();
258 void ResetProfiles(); 258 void ResetProfiles();
259 void LogBuiltins(); 259 void LogBuiltins();
260 260
261 Isolate* isolate_; 261 Isolate* isolate_;
262 TimeDelta sampling_interval_; 262 base::TimeDelta sampling_interval_;
263 CpuProfilesCollection* profiles_; 263 CpuProfilesCollection* profiles_;
264 ProfileGenerator* generator_; 264 ProfileGenerator* generator_;
265 ProfilerEventsProcessor* processor_; 265 ProfilerEventsProcessor* processor_;
266 bool saved_is_logging_; 266 bool saved_is_logging_;
267 bool is_profiling_; 267 bool is_profiling_;
268 268
269 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 269 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
270 }; 270 };
271 271
272 } } // namespace v8::internal 272 } } // namespace v8::internal
273 273
274 274
275 #endif // V8_CPU_PROFILER_H_ 275 #endif // V8_CPU_PROFILER_H_
OLDNEW
« src/base/macros.h ('K') | « src/cpu.cc ('k') | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698