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_; } | |
154 | 153 |
155 void Print(int indent); | 154 void Print(int indent); |
156 | 155 |
157 private: | 156 private: |
158 INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) { | 157 INLINE(static bool CodeEntriesMatch(void* entry1, void* entry2)) { |
159 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( | 158 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( |
160 reinterpret_cast<CodeEntry*>(entry2)); | 159 reinterpret_cast<CodeEntry*>(entry2)); |
161 } | 160 } |
162 | 161 |
163 INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) { | 162 INLINE(static uint32_t CodeEntryHash(CodeEntry* entry)) { |
164 return entry->GetCallUid(); | 163 return entry->GetCallUid(); |
165 } | 164 } |
166 | 165 |
167 ProfileTree* tree_; | 166 ProfileTree* tree_; |
168 CodeEntry* entry_; | 167 CodeEntry* entry_; |
169 unsigned total_ticks_; | 168 unsigned total_ticks_; |
170 unsigned self_ticks_; | 169 unsigned self_ticks_; |
171 // Mapping from CodeEntry* to ProfileNode* | 170 // Mapping from CodeEntry* to ProfileNode* |
172 HashMap children_; | 171 HashMap children_; |
173 List<ProfileNode*> children_list_; | 172 List<ProfileNode*> children_list_; |
174 unsigned id_; | |
175 | 173 |
176 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 174 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
177 }; | 175 }; |
178 | 176 |
179 | 177 |
180 class ProfileTree { | 178 class ProfileTree { |
181 public: | 179 public: |
182 ProfileTree(); | 180 ProfileTree(); |
183 ~ProfileTree(); | 181 ~ProfileTree(); |
184 | 182 |
185 ProfileNode* AddPathFromEnd(const Vector<CodeEntry*>& path); | 183 void AddPathFromEnd(const Vector<CodeEntry*>& path); |
186 void AddPathFromStart(const Vector<CodeEntry*>& path); | 184 void AddPathFromStart(const Vector<CodeEntry*>& path); |
187 void CalculateTotalTicks(); | 185 void CalculateTotalTicks(); |
188 void FilteredClone(ProfileTree* src, int security_token_id); | 186 void FilteredClone(ProfileTree* src, int security_token_id); |
189 | 187 |
190 double TicksToMillis(unsigned ticks) const { | 188 double TicksToMillis(unsigned ticks) const { |
191 return ticks * ms_to_ticks_scale_; | 189 return ticks * ms_to_ticks_scale_; |
192 } | 190 } |
193 ProfileNode* root() const { return root_; } | 191 ProfileNode* root() const { return root_; } |
194 void SetTickRatePerMs(double ticks_per_ms); | 192 void SetTickRatePerMs(double ticks_per_ms); |
195 | 193 |
196 unsigned next_node_id() { return next_node_id_++; } | |
197 | |
198 void ShortPrint(); | 194 void ShortPrint(); |
199 void Print() { | 195 void Print() { |
200 root_->Print(0); | 196 root_->Print(0); |
201 } | 197 } |
202 | 198 |
203 private: | 199 private: |
204 template <typename Callback> | 200 template <typename Callback> |
205 void TraverseDepthFirst(Callback* callback); | 201 void TraverseDepthFirst(Callback* callback); |
206 | 202 |
207 CodeEntry root_entry_; | 203 CodeEntry root_entry_; |
208 unsigned next_node_id_; | |
209 ProfileNode* root_; | 204 ProfileNode* root_; |
210 double ms_to_ticks_scale_; | 205 double ms_to_ticks_scale_; |
211 | 206 |
212 DISALLOW_COPY_AND_ASSIGN(ProfileTree); | 207 DISALLOW_COPY_AND_ASSIGN(ProfileTree); |
213 }; | 208 }; |
214 | 209 |
215 | 210 |
216 class CpuProfile { | 211 class CpuProfile { |
217 public: | 212 public: |
218 CpuProfile(const char* title, unsigned uid, bool record_samples) | 213 CpuProfile(const char* title, unsigned uid) |
219 : title_(title), uid_(uid), record_samples_(record_samples) { } | 214 : title_(title), uid_(uid) { } |
220 | 215 |
221 // Add pc -> ... -> main() call path to the profile. | 216 // Add pc -> ... -> main() call path to the profile. |
222 void AddPath(const Vector<CodeEntry*>& path); | 217 void AddPath(const Vector<CodeEntry*>& path); |
223 void CalculateTotalTicks(); | 218 void CalculateTotalTicks(); |
224 void SetActualSamplingRate(double actual_sampling_rate); | 219 void SetActualSamplingRate(double actual_sampling_rate); |
225 CpuProfile* FilteredClone(int security_token_id); | 220 CpuProfile* FilteredClone(int security_token_id); |
226 | 221 |
227 INLINE(const char* title() const) { return title_; } | 222 INLINE(const char* title() const) { return title_; } |
228 INLINE(unsigned uid() const) { return uid_; } | 223 INLINE(unsigned uid() const) { return uid_; } |
229 INLINE(const ProfileTree* top_down() const) { return &top_down_; } | 224 INLINE(const ProfileTree* top_down() const) { return &top_down_; } |
230 | 225 |
231 INLINE(int samples_count() const) { return samples_.length(); } | |
232 INLINE(ProfileNode* sample(int index) const) { return samples_.at(index); } | |
233 | |
234 void UpdateTicksScale(); | 226 void UpdateTicksScale(); |
235 | 227 |
236 void ShortPrint(); | 228 void ShortPrint(); |
237 void Print(); | 229 void Print(); |
238 | 230 |
239 private: | 231 private: |
240 const char* title_; | 232 const char* title_; |
241 unsigned uid_; | 233 unsigned uid_; |
242 bool record_samples_; | |
243 List<ProfileNode*> samples_; | |
244 ProfileTree top_down_; | 234 ProfileTree top_down_; |
245 | 235 |
246 DISALLOW_COPY_AND_ASSIGN(CpuProfile); | 236 DISALLOW_COPY_AND_ASSIGN(CpuProfile); |
247 }; | 237 }; |
248 | 238 |
249 | 239 |
250 class CodeMap { | 240 class CodeMap { |
251 public: | 241 public: |
252 CodeMap() : next_shared_id_(1) { } | 242 CodeMap() : next_shared_id_(1) { } |
253 void AddCode(Address addr, CodeEntry* entry, unsigned size); | 243 void AddCode(Address addr, CodeEntry* entry, unsigned size); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 281 |
292 DISALLOW_COPY_AND_ASSIGN(CodeMap); | 282 DISALLOW_COPY_AND_ASSIGN(CodeMap); |
293 }; | 283 }; |
294 | 284 |
295 | 285 |
296 class CpuProfilesCollection { | 286 class CpuProfilesCollection { |
297 public: | 287 public: |
298 CpuProfilesCollection(); | 288 CpuProfilesCollection(); |
299 ~CpuProfilesCollection(); | 289 ~CpuProfilesCollection(); |
300 | 290 |
301 bool StartProfiling(const char* title, unsigned uid, bool record_samples); | 291 bool StartProfiling(const char* title, unsigned uid); |
| 292 bool StartProfiling(String* title, unsigned uid); |
302 CpuProfile* StopProfiling(int security_token_id, | 293 CpuProfile* StopProfiling(int security_token_id, |
303 const char* title, | 294 const char* title, |
304 double actual_sampling_rate); | 295 double actual_sampling_rate); |
305 List<CpuProfile*>* Profiles(int security_token_id); | 296 List<CpuProfile*>* Profiles(int security_token_id); |
306 const char* GetName(Name* name) { | 297 const char* GetName(Name* name) { |
307 return function_and_resource_names_.GetName(name); | 298 return function_and_resource_names_.GetName(name); |
308 } | 299 } |
309 const char* GetName(int args_count) { | 300 const char* GetName(int args_count) { |
310 return function_and_resource_names_.GetName(args_count); | 301 return function_and_resource_names_.GetName(args_count); |
311 } | 302 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 CodeEntry* gc_entry_; | 441 CodeEntry* gc_entry_; |
451 SampleRateCalculator sample_rate_calc_; | 442 SampleRateCalculator sample_rate_calc_; |
452 | 443 |
453 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 444 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
454 }; | 445 }; |
455 | 446 |
456 | 447 |
457 } } // namespace v8::internal | 448 } } // namespace v8::internal |
458 | 449 |
459 #endif // V8_PROFILE_GENERATOR_H_ | 450 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |