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

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

Issue 2079273003: Revert of Refactor CpuProfiler. (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
« no previous file with comments | « src/profiler/cpu-profiler.cc ('k') | src/profiler/profile-generator.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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 Address instruction_start() const { return instruction_start_; } 107 Address instruction_start() const { return instruction_start_; }
108 CodeEventListener::LogEventsAndTags tag() const { 108 CodeEventListener::LogEventsAndTags tag() const {
109 return TagField::decode(bit_field_); 109 return TagField::decode(bit_field_);
110 } 110 }
111 111
112 static const char* const kEmptyNamePrefix; 112 static const char* const kEmptyNamePrefix;
113 static const char* const kEmptyResourceName; 113 static const char* const kEmptyResourceName;
114 static const char* const kEmptyBailoutReason; 114 static const char* const kEmptyBailoutReason;
115 static const char* const kNoDeoptReason; 115 static const char* const kNoDeoptReason;
116 116
117 static const char* const kProgramEntryName;
118 static const char* const kIdleEntryName;
119 static const char* const kGarbageCollectorEntryName;
120 // Used to represent frames for which we have no reliable way to
121 // detect function.
122 static const char* const kUnresolvedFunctionName;
123
124 V8_INLINE static CodeEntry* program_entry() {
125 return kProgramEntry.Pointer();
126 }
127 V8_INLINE static CodeEntry* idle_entry() { return kIdleEntry.Pointer(); }
128 V8_INLINE static CodeEntry* gc_entry() { return kGCEntry.Pointer(); }
129 V8_INLINE static CodeEntry* unresolved_entry() {
130 return kUnresolvedEntry.Pointer();
131 }
132
133 private: 117 private:
134 struct ProgramEntryCreateTrait {
135 static CodeEntry* Create();
136 };
137 struct IdleEntryCreateTrait {
138 static CodeEntry* Create();
139 };
140 struct GCEntryCreateTrait {
141 static CodeEntry* Create();
142 };
143 struct UnresolvedEntryCreateTrait {
144 static CodeEntry* Create();
145 };
146
147 static base::LazyDynamicInstance<CodeEntry, ProgramEntryCreateTrait>::type
148 kProgramEntry;
149 static base::LazyDynamicInstance<CodeEntry, IdleEntryCreateTrait>::type
150 kIdleEntry;
151 static base::LazyDynamicInstance<CodeEntry, GCEntryCreateTrait>::type
152 kGCEntry;
153 static base::LazyDynamicInstance<CodeEntry, UnresolvedEntryCreateTrait>::type
154 kUnresolvedEntry;
155
156 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; 118 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {};
157 class BuiltinIdField : public BitField<Builtins::Name, 8, 24> {}; 119 class BuiltinIdField : public BitField<Builtins::Name, 8, 24> {};
158 120
159 uint32_t bit_field_; 121 uint32_t bit_field_;
160 const char* name_prefix_; 122 const char* name_prefix_;
161 const char* name_; 123 const char* name_;
162 const char* resource_name_; 124 const char* resource_name_;
163 int line_number_; 125 int line_number_;
164 int column_number_; 126 int column_number_;
165 int script_id_; 127 int script_id_;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 293
332 class CpuProfilesCollection { 294 class CpuProfilesCollection {
333 public: 295 public:
334 explicit CpuProfilesCollection(Isolate* isolate); 296 explicit CpuProfilesCollection(Isolate* isolate);
335 ~CpuProfilesCollection(); 297 ~CpuProfilesCollection();
336 298
337 void set_cpu_profiler(CpuProfiler* profiler) { profiler_ = profiler; } 299 void set_cpu_profiler(CpuProfiler* profiler) { profiler_ = profiler; }
338 bool StartProfiling(const char* title, bool record_samples); 300 bool StartProfiling(const char* title, bool record_samples);
339 CpuProfile* StopProfiling(const char* title); 301 CpuProfile* StopProfiling(const char* title);
340 List<CpuProfile*>* profiles() { return &finished_profiles_; } 302 List<CpuProfile*>* profiles() { return &finished_profiles_; }
341 const char* GetName(Name* name) { return resource_names_.GetName(name); } 303 const char* GetName(Name* name) {
304 return function_and_resource_names_.GetName(name);
305 }
306 const char* GetName(int args_count) {
307 return function_and_resource_names_.GetName(args_count);
308 }
309 const char* GetFunctionName(Name* name) {
310 return function_and_resource_names_.GetFunctionName(name);
311 }
312 const char* GetFunctionName(const char* name) {
313 return function_and_resource_names_.GetFunctionName(name);
314 }
342 bool IsLastProfile(const char* title); 315 bool IsLastProfile(const char* title);
343 void RemoveProfile(CpuProfile* profile); 316 void RemoveProfile(CpuProfile* profile);
344 317
318 CodeEntry* NewCodeEntry(
319 CodeEventListener::LogEventsAndTags tag, const char* name,
320 const char* name_prefix = CodeEntry::kEmptyNamePrefix,
321 const char* resource_name = CodeEntry::kEmptyResourceName,
322 int line_number = v8::CpuProfileNode::kNoLineNumberInfo,
323 int column_number = v8::CpuProfileNode::kNoColumnNumberInfo,
324 JITLineInfoTable* line_info = NULL, Address instruction_start = NULL);
325
345 // Called from profile generator thread. 326 // Called from profile generator thread.
346 void AddPathToCurrentProfiles(base::TimeTicks timestamp, 327 void AddPathToCurrentProfiles(base::TimeTicks timestamp,
347 const std::vector<CodeEntry*>& path, 328 const std::vector<CodeEntry*>& path,
348 int src_line, bool update_stats); 329 int src_line, bool update_stats);
349 330
350 // Limits the number of profiles that can be simultaneously collected. 331 // Limits the number of profiles that can be simultaneously collected.
351 static const int kMaxSimultaneousProfiles = 100; 332 static const int kMaxSimultaneousProfiles = 100;
352 333
353 private: 334 private:
354 StringsStorage resource_names_; 335 StringsStorage function_and_resource_names_;
336 List<CodeEntry*> code_entries_;
355 List<CpuProfile*> finished_profiles_; 337 List<CpuProfile*> finished_profiles_;
356 CpuProfiler* profiler_; 338 CpuProfiler* profiler_;
357 339
358 // Accessed by VM thread and profile generator thread. 340 // Accessed by VM thread and profile generator thread.
359 List<CpuProfile*> current_profiles_; 341 List<CpuProfile*> current_profiles_;
360 base::Semaphore current_profiles_semaphore_; 342 base::Semaphore current_profiles_semaphore_;
361 343
362 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); 344 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection);
363 }; 345 };
364 346
365 347
366 class ProfileGenerator { 348 class ProfileGenerator {
367 public: 349 public:
368 explicit ProfileGenerator(CpuProfilesCollection* profiles); 350 explicit ProfileGenerator(CpuProfilesCollection* profiles);
369 351
370 void RecordTickSample(const TickSample& sample); 352 void RecordTickSample(const TickSample& sample);
371 353
372 CodeMap* code_map() { return &code_map_; } 354 CodeMap* code_map() { return &code_map_; }
373 355
356 static const char* const kProgramEntryName;
357 static const char* const kIdleEntryName;
358 static const char* const kGarbageCollectorEntryName;
359 // Used to represent frames for which we have no reliable way to
360 // detect function.
361 static const char* const kUnresolvedFunctionName;
362
374 private: 363 private:
375 CodeEntry* EntryForVMState(StateTag tag); 364 CodeEntry* EntryForVMState(StateTag tag);
376 365
377 CpuProfilesCollection* profiles_; 366 CpuProfilesCollection* profiles_;
378 CodeMap code_map_; 367 CodeMap code_map_;
368 CodeEntry* program_entry_;
369 CodeEntry* idle_entry_;
370 CodeEntry* gc_entry_;
371 CodeEntry* unresolved_entry_;
379 372
380 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); 373 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
381 }; 374 };
382 375
383 376
384 } // namespace internal 377 } // namespace internal
385 } // namespace v8 378 } // namespace v8
386 379
387 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ 380 #endif // V8_PROFILER_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.cc ('k') | src/profiler/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698