| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 INLINE(void IncrementSelfTicks()) { ++self_ticks_; } | 143 INLINE(void IncrementSelfTicks()) { ++self_ticks_; } |
| 144 INLINE(void IncreaseSelfTicks(unsigned amount)) { self_ticks_ += amount; } | 144 INLINE(void IncreaseSelfTicks(unsigned amount)) { self_ticks_ += amount; } |
| 145 INLINE(void IncreaseTotalTicks(unsigned amount)) { total_ticks_ += amount; } | 145 INLINE(void IncreaseTotalTicks(unsigned amount)) { total_ticks_ += amount; } |
| 146 | 146 |
| 147 INLINE(CodeEntry* entry() const) { return entry_; } | 147 INLINE(CodeEntry* entry() const) { return entry_; } |
| 148 INLINE(unsigned self_ticks() const) { return self_ticks_; } | 148 INLINE(unsigned self_ticks() const) { return self_ticks_; } |
| 149 INLINE(unsigned total_ticks() const) { return total_ticks_; } | 149 INLINE(unsigned total_ticks() const) { return total_ticks_; } |
| 150 INLINE(const List<ProfileNode*>* children() const) { return &children_list_; } | 150 INLINE(const List<ProfileNode*>* children() const) { return &children_list_; } |
| 151 double GetSelfMillis() const; | 151 double GetSelfMillis() const; |
| 152 double GetTotalMillis() const; | 152 double GetTotalMillis() const; |
| 153 unsigned id() const { return id_; } |
| 153 | 154 |
| 154 void Print(int indent); | 155 void Print(int indent); |
| 155 | 156 |
| 156 private: | 157 private: |
| 157 INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) { | 158 INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) { |
| 158 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( | 159 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( |
| 159 reinterpret_cast<CodeEntry*>(entry2)); | 160 reinterpret_cast<CodeEntry*>(entry2)); |
| 160 } | 161 } |
| 161 | 162 |
| 162 INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) { | 163 INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) { |
| 163 return entry->GetCallUid(); | 164 return entry->GetCallUid(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 ProfileTree* tree_; | 167 ProfileTree* tree_; |
| 167 CodeEntry* entry_; | 168 CodeEntry* entry_; |
| 168 unsigned total_ticks_; | 169 unsigned total_ticks_; |
| 169 unsigned self_ticks_; | 170 unsigned self_ticks_; |
| 170 // Mapping from CodeEntry* to ProfileNode* | 171 // Mapping from CodeEntry* to ProfileNode* |
| 171 HashMap children_; | 172 HashMap children_; |
| 172 List<ProfileNode*> children_list_; | 173 List<ProfileNode*> children_list_; |
| 174 unsigned id_; |
| 173 | 175 |
| 174 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 176 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
| 175 }; | 177 }; |
| 176 | 178 |
| 177 | 179 |
| 178 class ProfileTree { | 180 class ProfileTree { |
| 179 public: | 181 public: |
| 180 ProfileTree(); | 182 ProfileTree(); |
| 181 ~ProfileTree(); | 183 ~ProfileTree(); |
| 182 | 184 |
| 183 void AddPathFromEnd(const Vector<CodeEntry*>& path); | 185 ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path); |
| 184 void AddPathFromStart(const Vector<CodeEntry*>& path); | 186 void AddPathFromStart(const Vector<CodeEntry*>& path); |
| 185 void CalculateTotalTicks(); | 187 void CalculateTotalTicks(); |
| 186 void FilteredClone(ProfileTree* src, int security_token_id); | 188 void FilteredClone(ProfileTree* src, int security_token_id); |
| 187 | 189 |
| 188 double TicksToMillis(unsigned ticks) const { | 190 double TicksToMillis(unsigned ticks) const { |
| 189 return ticks * ms_to_ticks_scale_; | 191 return ticks * ms_to_ticks_scale_; |
| 190 } | 192 } |
| 191 ProfileNode* root() const { return root_; } | 193 ProfileNode* root() const { return root_; } |
| 192 void SetTickRatePerMs(double ticks_per_ms); | 194 void SetTickRatePerMs(double ticks_per_ms); |
| 193 | 195 |
| 196 unsigned next_node_id() { return next_node_id_++; } |
| 197 |
| 194 void ShortPrint(); | 198 void ShortPrint(); |
| 195 void Print() { | 199 void Print() { |
| 196 root_->Print(0); | 200 root_->Print(0); |
| 197 } | 201 } |
| 198 | 202 |
| 199 private: | 203 private: |
| 200 template <typename Callback> | 204 template <typename Callback> |
| 201 void TraverseDepthFirst(Callback* callback); | 205 void TraverseDepthFirst(Callback* callback); |
| 202 | 206 |
| 203 CodeEntry root_entry_; | 207 CodeEntry root_entry_; |
| 208 unsigned next_node_id_; |
| 204 ProfileNode* root_; | 209 ProfileNode* root_; |
| 205 double ms_to_ticks_scale_; | 210 double ms_to_ticks_scale_; |
| 206 | 211 |
| 207 DISALLOW_COPY_AND_ASSIGN(ProfileTree); | 212 DISALLOW_COPY_AND_ASSIGN(ProfileTree); |
| 208 }; | 213 }; |
| 209 | 214 |
| 210 | 215 |
| 211 class CpuProfile { | 216 class CpuProfile { |
| 212 public: | 217 public: |
| 213 CpuProfile(const char* title, unsigned uid) | 218 CpuProfile(const char* title, unsigned uid, bool record_samples) |
| 214 : title_(title), uid_(uid) { } | 219 : title_(title), uid_(uid), record_samples_(record_samples) { } |
| 215 | 220 |
| 216 // Add pc -> ... -> main() call path to the profile. | 221 // Add pc -> ... -> main() call path to the profile. |
| 217 void AddPath(const Vector<CodeEntry*>& path); | 222 void AddPath(const Vector<CodeEntry*>& path); |
| 218 void CalculateTotalTicks(); | 223 void CalculateTotalTicks(); |
| 219 void SetActualSamplingRate(double actual_sampling_rate); | 224 void SetActualSamplingRate(double actual_sampling_rate); |
| 220 CpuProfile* FilteredClone(int security_token_id); | 225 CpuProfile* FilteredClone(int security_token_id); |
| 221 | 226 |
| 222 INLINE(const char* title() const) { return title_; } | 227 INLINE(const char* title() const) { return title_; } |
| 223 INLINE(unsigned uid() const) { return uid_; } | 228 INLINE(unsigned uid() const) { return uid_; } |
| 224 INLINE(const ProfileTree* top_down() const) { return &top_down_; } | 229 INLINE(const ProfileTree* top_down() const) { return &top_down_; } |
| 225 | 230 |
| 231 INLINE(int samples_count() const) { return samples_.length(); } |
| 232 INLINE(ProfileNode* sample(int index) const) { return samples_.at(index); } |
| 233 |
| 226 void UpdateTicksScale(); | 234 void UpdateTicksScale(); |
| 227 | 235 |
| 228 void ShortPrint(); | 236 void ShortPrint(); |
| 229 void Print(); | 237 void Print(); |
| 230 | 238 |
| 231 private: | 239 private: |
| 232 const char* title_; | 240 const char* title_; |
| 233 unsigned uid_; | 241 unsigned uid_; |
| 242 bool record_samples_; |
| 243 List<ProfileNode*> samples_; |
| 234 ProfileTree top_down_; | 244 ProfileTree top_down_; |
| 235 | 245 |
| 236 DISALLOW_COPY_AND_ASSIGN(CpuProfile); | 246 DISALLOW_COPY_AND_ASSIGN(CpuProfile); |
| 237 }; | 247 }; |
| 238 | 248 |
| 239 | 249 |
| 240 class CodeMap { | 250 class CodeMap { |
| 241 public: | 251 public: |
| 242 CodeMap() : next_shared_id_(1) { } | 252 CodeMap() : next_shared_id_(1) { } |
| 243 void AddCode(Address addr, CodeEntry* entry, unsigned size); | 253 void AddCode(Address addr, CodeEntry* entry, unsigned size); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 291 |
| 282 DISALLOW_COPY_AND_ASSIGN(CodeMap); | 292 DISALLOW_COPY_AND_ASSIGN(CodeMap); |
| 283 }; | 293 }; |
| 284 | 294 |
| 285 | 295 |
| 286 class CpuProfilesCollection { | 296 class CpuProfilesCollection { |
| 287 public: | 297 public: |
| 288 CpuProfilesCollection(); | 298 CpuProfilesCollection(); |
| 289 ~CpuProfilesCollection(); | 299 ~CpuProfilesCollection(); |
| 290 | 300 |
| 291 bool StartProfiling(const char* title, unsigned uid); | 301 bool StartProfiling(const char* title, unsigned uid, bool record_samples); |
| 292 bool StartProfiling(String* title, unsigned uid); | |
| 293 CpuProfile* StopProfiling(int security_token_id, | 302 CpuProfile* StopProfiling(int security_token_id, |
| 294 const char* title, | 303 const char* title, |
| 295 double actual_sampling_rate); | 304 double actual_sampling_rate); |
| 296 List<CpuProfile*>* Profiles(int security_token_id); | 305 List<CpuProfile*>* Profiles(int security_token_id); |
| 297 const char* GetName(Name* name) { | 306 const char* GetName(Name* name) { |
| 298 return function_and_resource_names_.GetName(name); | 307 return function_and_resource_names_.GetName(name); |
| 299 } | 308 } |
| 300 const char* GetName(int args_count) { | 309 const char* GetName(int args_count) { |
| 301 return function_and_resource_names_.GetName(args_count); | 310 return function_and_resource_names_.GetName(args_count); |
| 302 } | 311 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 CodeEntry* gc_entry_; | 450 CodeEntry* gc_entry_; |
| 442 SampleRateCalculator sample_rate_calc_; | 451 SampleRateCalculator sample_rate_calc_; |
| 443 | 452 |
| 444 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 453 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
| 445 }; | 454 }; |
| 446 | 455 |
| 447 | 456 |
| 448 } } // namespace v8::internal | 457 } } // namespace v8::internal |
| 449 | 458 |
| 450 #endif // V8_PROFILE_GENERATOR_H_ | 459 #endif // V8_PROFILE_GENERATOR_H_ |
| OLD | NEW |