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

Side by Side Diff: src/profiler/profile-generator.h

Issue 2056253003: Remove Isolate::cpu_profiler() usage in api.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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_PROFILE_GENERATOR_H_ 5 #ifndef V8_PROFILER_PROFILE_GENERATOR_H_
6 #define V8_PROFILER_PROFILE_GENERATOR_H_ 6 #define V8_PROFILER_PROFILE_GENERATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include "include/v8-profiler.h" 9 #include "include/v8-profiler.h"
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 unsigned next_function_id_; 222 unsigned next_function_id_;
223 base::HashMap function_ids_; 223 base::HashMap function_ids_;
224 224
225 DISALLOW_COPY_AND_ASSIGN(ProfileTree); 225 DISALLOW_COPY_AND_ASSIGN(ProfileTree);
226 }; 226 };
227 227
228 228
229 class CpuProfile { 229 class CpuProfile {
230 public: 230 public:
231 CpuProfile(Isolate* isolate, const char* title, bool record_samples); 231 CpuProfile(CpuProfiler* profiler, const char* title, bool record_samples);
232 232
233 // Add pc -> ... -> main() call path to the profile. 233 // Add pc -> ... -> main() call path to the profile.
234 void AddPath(base::TimeTicks timestamp, const std::vector<CodeEntry*>& path, 234 void AddPath(base::TimeTicks timestamp, const std::vector<CodeEntry*>& path,
235 int src_line, bool update_stats); 235 int src_line, bool update_stats);
236 void CalculateTotalTicksAndSamplingRate(); 236 void CalculateTotalTicksAndSamplingRate();
237 237
238 const char* title() const { return title_; } 238 const char* title() const { return title_; }
239 const ProfileTree* top_down() const { return &top_down_; } 239 const ProfileTree* top_down() const { return &top_down_; }
240 240
241 int samples_count() const { return samples_.length(); } 241 int samples_count() const { return samples_.length(); }
242 ProfileNode* sample(int index) const { return samples_.at(index); } 242 ProfileNode* sample(int index) const { return samples_.at(index); }
243 base::TimeTicks sample_timestamp(int index) const { 243 base::TimeTicks sample_timestamp(int index) const {
244 return timestamps_.at(index); 244 return timestamps_.at(index);
245 } 245 }
246 246
247 base::TimeTicks start_time() const { return start_time_; } 247 base::TimeTicks start_time() const { return start_time_; }
248 base::TimeTicks end_time() const { return end_time_; } 248 base::TimeTicks end_time() const { return end_time_; }
249 CpuProfiler* cpu_profiler() const { return profiler_; }
249 250
250 void UpdateTicksScale(); 251 void UpdateTicksScale();
251 252
252 void Print(); 253 void Print();
253 254
254 private: 255 private:
255 const char* title_; 256 const char* title_;
256 bool record_samples_; 257 bool record_samples_;
257 base::TimeTicks start_time_; 258 base::TimeTicks start_time_;
258 base::TimeTicks end_time_; 259 base::TimeTicks end_time_;
259 List<ProfileNode*> samples_; 260 List<ProfileNode*> samples_;
260 List<base::TimeTicks> timestamps_; 261 List<base::TimeTicks> timestamps_;
261 ProfileTree top_down_; 262 ProfileTree top_down_;
263 CpuProfiler* const profiler_;
262 264
263 DISALLOW_COPY_AND_ASSIGN(CpuProfile); 265 DISALLOW_COPY_AND_ASSIGN(CpuProfile);
264 }; 266 };
265 267
266 class CodeMap { 268 class CodeMap {
267 public: 269 public:
268 CodeMap() {} 270 CodeMap() {}
269 271
270 void AddCode(Address addr, CodeEntry* entry, unsigned size); 272 void AddCode(Address addr, CodeEntry* entry, unsigned size);
271 void MoveCode(Address from, Address to); 273 void MoveCode(Address from, Address to);
(...skipping 10 matching lines...) Expand all
282 284
283 void DeleteAllCoveredCode(Address start, Address end); 285 void DeleteAllCoveredCode(Address start, Address end);
284 286
285 std::map<Address, CodeEntryInfo> code_map_; 287 std::map<Address, CodeEntryInfo> code_map_;
286 288
287 DISALLOW_COPY_AND_ASSIGN(CodeMap); 289 DISALLOW_COPY_AND_ASSIGN(CodeMap);
288 }; 290 };
289 291
290 class CpuProfilesCollection { 292 class CpuProfilesCollection {
291 public: 293 public:
292 explicit CpuProfilesCollection(Heap* heap); 294 explicit CpuProfilesCollection(Isolate* isolate);
293 ~CpuProfilesCollection(); 295 ~CpuProfilesCollection();
294 296
297 void set_cpu_profiler(CpuProfiler* profiler) { profiler_ = profiler; }
295 bool StartProfiling(const char* title, bool record_samples); 298 bool StartProfiling(const char* title, bool record_samples);
296 CpuProfile* StopProfiling(const char* title); 299 CpuProfile* StopProfiling(const char* title);
297 List<CpuProfile*>* profiles() { return &finished_profiles_; } 300 List<CpuProfile*>* profiles() { return &finished_profiles_; }
298 const char* GetName(Name* name) { 301 const char* GetName(Name* name) {
299 return function_and_resource_names_.GetName(name); 302 return function_and_resource_names_.GetName(name);
300 } 303 }
301 const char* GetName(int args_count) { 304 const char* GetName(int args_count) {
302 return function_and_resource_names_.GetName(args_count); 305 return function_and_resource_names_.GetName(args_count);
303 } 306 }
304 const char* GetFunctionName(Name* name) { 307 const char* GetFunctionName(Name* name) {
(...skipping 18 matching lines...) Expand all
323 const std::vector<CodeEntry*>& path, 326 const std::vector<CodeEntry*>& path,
324 int src_line, bool update_stats); 327 int src_line, bool update_stats);
325 328
326 // Limits the number of profiles that can be simultaneously collected. 329 // Limits the number of profiles that can be simultaneously collected.
327 static const int kMaxSimultaneousProfiles = 100; 330 static const int kMaxSimultaneousProfiles = 100;
328 331
329 private: 332 private:
330 StringsStorage function_and_resource_names_; 333 StringsStorage function_and_resource_names_;
331 List<CodeEntry*> code_entries_; 334 List<CodeEntry*> code_entries_;
332 List<CpuProfile*> finished_profiles_; 335 List<CpuProfile*> finished_profiles_;
333 336 CpuProfiler* profiler_;
334 Isolate* isolate_;
335 337
336 // Accessed by VM thread and profile generator thread. 338 // Accessed by VM thread and profile generator thread.
337 List<CpuProfile*> current_profiles_; 339 List<CpuProfile*> current_profiles_;
338 base::Semaphore current_profiles_semaphore_; 340 base::Semaphore current_profiles_semaphore_;
339 341
340 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); 342 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection);
341 }; 343 };
342 344
343 345
344 class ProfileGenerator { 346 class ProfileGenerator {
(...skipping 22 matching lines...) Expand all
367 CodeEntry* unresolved_entry_; 369 CodeEntry* unresolved_entry_;
368 370
369 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); 371 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
370 }; 372 };
371 373
372 374
373 } // namespace internal 375 } // namespace internal
374 } // namespace v8 376 } // namespace v8
375 377
376 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ 378 #endif // V8_PROFILER_PROFILE_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698