OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const char* name, | 43 const char* name, |
44 const char* resource_name, | 44 const char* resource_name, |
45 int line_number)); | 45 int line_number)); |
46 | 46 |
47 INLINE(bool is_js_function() const); | 47 INLINE(bool is_js_function() const); |
48 INLINE(const char* name_prefix() const) { return name_prefix_; } | 48 INLINE(const char* name_prefix() const) { return name_prefix_; } |
49 INLINE(bool has_name_prefix() const) { return name_prefix_[0] != '\0'; } | 49 INLINE(bool has_name_prefix() const) { return name_prefix_[0] != '\0'; } |
50 INLINE(const char* name() const) { return name_; } | 50 INLINE(const char* name() const) { return name_; } |
51 INLINE(const char* resource_name() const) { return resource_name_; } | 51 INLINE(const char* resource_name() const) { return resource_name_; } |
52 INLINE(int line_number() const) { return line_number_; } | 52 INLINE(int line_number() const) { return line_number_; } |
| 53 INLINE(unsigned long call_uid() const) { return call_uid_; } |
53 | 54 |
54 static const char* kEmptyNamePrefix; | 55 static const char* kEmptyNamePrefix; |
55 static const int kNoLineNumberInfo; | |
56 | 56 |
57 private: | 57 private: |
| 58 const unsigned long call_uid_; |
58 Logger::LogEventsAndTags tag_; | 59 Logger::LogEventsAndTags tag_; |
59 const char* name_prefix_; | 60 const char* name_prefix_; |
60 const char* name_; | 61 const char* name_; |
61 const char* resource_name_; | 62 const char* resource_name_; |
62 int line_number_; | 63 int line_number_; |
63 | 64 |
| 65 static unsigned long next_call_uid_; |
| 66 |
64 DISALLOW_COPY_AND_ASSIGN(CodeEntry); | 67 DISALLOW_COPY_AND_ASSIGN(CodeEntry); |
65 }; | 68 }; |
66 | 69 |
67 | 70 |
68 class ProfileNode { | 71 class ProfileNode { |
69 public: | 72 public: |
70 INLINE(explicit ProfileNode(CodeEntry* entry)); | 73 INLINE(explicit ProfileNode(CodeEntry* entry)); |
71 | 74 |
72 ProfileNode* FindChild(CodeEntry* entry); | 75 ProfileNode* FindChild(CodeEntry* entry); |
73 ProfileNode* FindOrAddChild(CodeEntry* entry); | 76 ProfileNode* FindOrAddChild(CodeEntry* entry); |
(...skipping 22 matching lines...) Expand all Loading... |
96 // CodeEntry* -> ProfileNode* | 99 // CodeEntry* -> ProfileNode* |
97 HashMap children_; | 100 HashMap children_; |
98 List<ProfileNode*> children_list_; | 101 List<ProfileNode*> children_list_; |
99 | 102 |
100 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 103 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
101 }; | 104 }; |
102 | 105 |
103 | 106 |
104 class ProfileTree { | 107 class ProfileTree { |
105 public: | 108 public: |
106 ProfileTree() : root_(new ProfileNode(NULL)) { } | 109 ProfileTree(); |
107 ~ProfileTree(); | 110 ~ProfileTree(); |
108 | 111 |
109 void AddPathFromEnd(const Vector<CodeEntry*>& path); | 112 void AddPathFromEnd(const Vector<CodeEntry*>& path); |
110 void AddPathFromStart(const Vector<CodeEntry*>& path); | 113 void AddPathFromStart(const Vector<CodeEntry*>& path); |
111 void CalculateTotalTicks(); | 114 void CalculateTotalTicks(); |
112 | 115 |
113 ProfileNode* root() const { return root_; } | 116 ProfileNode* root() const { return root_; } |
114 | 117 |
115 void ShortPrint(); | 118 void ShortPrint(); |
116 void Print() { | 119 void Print() { |
117 root_->Print(0); | 120 root_->Print(0); |
118 } | 121 } |
119 | 122 |
120 private: | 123 private: |
121 template <typename Callback> | 124 template <typename Callback> |
122 void TraverseBreadthFirstPostOrder(Callback* callback); | 125 void TraverseBreadthFirstPostOrder(Callback* callback); |
123 | 126 |
| 127 CodeEntry root_entry_; |
124 ProfileNode* root_; | 128 ProfileNode* root_; |
125 | 129 |
126 DISALLOW_COPY_AND_ASSIGN(ProfileTree); | 130 DISALLOW_COPY_AND_ASSIGN(ProfileTree); |
127 }; | 131 }; |
128 | 132 |
129 | 133 |
130 class CpuProfile { | 134 class CpuProfile { |
131 public: | 135 public: |
132 CpuProfile(const char* title, unsigned uid) | 136 CpuProfile(const char* title, unsigned uid) |
133 : title_(title), uid_(uid) { } | 137 : title_(title), uid_(uid) { } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 String* name, String* resource_name, int line_number); | 216 String* name, String* resource_name, int line_number); |
213 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); | 217 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); |
214 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 218 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
215 const char* name_prefix, String* name); | 219 const char* name_prefix, String* name); |
216 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); | 220 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); |
217 | 221 |
218 // Called from profile generator thread. | 222 // Called from profile generator thread. |
219 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); | 223 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); |
220 | 224 |
221 private: | 225 private: |
| 226 const char* GetFunctionName(String* name); |
222 const char* GetName(String* name); | 227 const char* GetName(String* name); |
223 const char* GetName(int args_count); | 228 const char* GetName(int args_count); |
224 | 229 |
225 INLINE(static bool StringsMatch(void* key1, void* key2)) { | 230 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
226 return strcmp(reinterpret_cast<char*>(key1), | 231 return strcmp(reinterpret_cast<char*>(key1), |
227 reinterpret_cast<char*>(key2)) == 0; | 232 reinterpret_cast<char*>(key2)) == 0; |
228 } | 233 } |
229 | 234 |
230 INLINE(static bool CpuProfilesMatch(void* key1, void* key2)) { | 235 INLINE(static bool CpuProfilesMatch(void* key1, void* key2)) { |
231 return key1 == key2; | 236 return key1 == key2; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return profiles_->NewCodeEntry(tag, args_count); | 280 return profiles_->NewCodeEntry(tag, args_count); |
276 } | 281 } |
277 | 282 |
278 void RecordTickSample(const TickSample& sample); | 283 void RecordTickSample(const TickSample& sample); |
279 | 284 |
280 INLINE(CodeMap* code_map()) { return &code_map_; } | 285 INLINE(CodeMap* code_map()) { return &code_map_; } |
281 | 286 |
282 private: | 287 private: |
283 CpuProfilesCollection* profiles_; | 288 CpuProfilesCollection* profiles_; |
284 CodeMap code_map_; | 289 CodeMap code_map_; |
| 290 CodeEntry* program_entry_; |
285 | 291 |
286 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 292 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
287 }; | 293 }; |
288 | 294 |
289 } } // namespace v8::internal | 295 } } // namespace v8::internal |
290 | 296 |
291 #endif // ENABLE_CPP_PROFILES_PROCESSOR | 297 #endif // ENABLE_CPP_PROFILES_PROCESSOR |
292 | 298 |
293 #endif // V8_PROFILE_GENERATOR_H_ | 299 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |