OLD | NEW |
---|---|
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 const List<ProfileNode*>* children() const { return &children_list_; } | 149 const List<ProfileNode*>* children() const { return &children_list_; } |
150 unsigned id() const { return id_; } | 150 unsigned id() const { return id_; } |
151 unsigned function_id() const; | 151 unsigned function_id() const; |
152 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } | 152 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } |
153 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, | 153 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, |
154 unsigned int length) const; | 154 unsigned int length) const; |
155 void CollectDeoptInfo(CodeEntry* entry); | 155 void CollectDeoptInfo(CodeEntry* entry); |
156 const std::vector<CpuProfileDeoptInfo>& deopt_infos() const { | 156 const std::vector<CpuProfileDeoptInfo>& deopt_infos() const { |
157 return deopt_infos_; | 157 return deopt_infos_; |
158 } | 158 } |
159 ProfileTree* tree() const { return tree_; } | |
vogelheim
2015/11/27 16:06:15
... or isolate(); similar to previous comment.
| |
159 | 160 |
160 void Print(int indent); | 161 void Print(int indent); |
161 | 162 |
162 static bool CodeEntriesMatch(void* entry1, void* entry2) { | 163 static bool CodeEntriesMatch(void* entry1, void* entry2) { |
163 return reinterpret_cast<CodeEntry*>(entry1) | 164 return reinterpret_cast<CodeEntry*>(entry1) |
164 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); | 165 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2)); |
165 } | 166 } |
166 | 167 |
167 private: | 168 private: |
168 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } | 169 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); } |
(...skipping 10 matching lines...) Expand all Loading... | |
179 HashMap line_ticks_; | 180 HashMap line_ticks_; |
180 | 181 |
181 std::vector<CpuProfileDeoptInfo> deopt_infos_; | 182 std::vector<CpuProfileDeoptInfo> deopt_infos_; |
182 | 183 |
183 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 184 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
184 }; | 185 }; |
185 | 186 |
186 | 187 |
187 class ProfileTree { | 188 class ProfileTree { |
188 public: | 189 public: |
189 ProfileTree(); | 190 explicit ProfileTree(Isolate* isolate); |
190 ~ProfileTree(); | 191 ~ProfileTree(); |
191 | 192 |
192 ProfileNode* AddPathFromEnd( | 193 ProfileNode* AddPathFromEnd( |
193 const Vector<CodeEntry*>& path, | 194 const Vector<CodeEntry*>& path, |
194 int src_line = v8::CpuProfileNode::kNoLineNumberInfo); | 195 int src_line = v8::CpuProfileNode::kNoLineNumberInfo); |
195 ProfileNode* root() const { return root_; } | 196 ProfileNode* root() const { return root_; } |
196 unsigned next_node_id() { return next_node_id_++; } | 197 unsigned next_node_id() { return next_node_id_++; } |
197 unsigned GetFunctionId(const ProfileNode* node); | 198 unsigned GetFunctionId(const ProfileNode* node); |
198 | 199 |
199 void Print() { | 200 void Print() { |
200 root_->Print(0); | 201 root_->Print(0); |
201 } | 202 } |
202 | 203 |
204 Isolate* isolate() const { return isolate_; } | |
205 | |
203 private: | 206 private: |
204 template <typename Callback> | 207 template <typename Callback> |
205 void TraverseDepthFirst(Callback* callback); | 208 void TraverseDepthFirst(Callback* callback); |
206 | 209 |
207 CodeEntry root_entry_; | 210 CodeEntry root_entry_; |
208 unsigned next_node_id_; | 211 unsigned next_node_id_; |
209 ProfileNode* root_; | 212 ProfileNode* root_; |
213 Isolate* isolate_; | |
210 | 214 |
211 unsigned next_function_id_; | 215 unsigned next_function_id_; |
212 HashMap function_ids_; | 216 HashMap function_ids_; |
213 | 217 |
214 DISALLOW_COPY_AND_ASSIGN(ProfileTree); | 218 DISALLOW_COPY_AND_ASSIGN(ProfileTree); |
215 }; | 219 }; |
216 | 220 |
217 | 221 |
218 class CpuProfile { | 222 class CpuProfile { |
219 public: | 223 public: |
220 CpuProfile(const char* title, bool record_samples); | 224 CpuProfile(Isolate* isolate, const char* title, bool record_samples); |
221 | 225 |
222 // Add pc -> ... -> main() call path to the profile. | 226 // Add pc -> ... -> main() call path to the profile. |
223 void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path, | 227 void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path, |
224 int src_line); | 228 int src_line); |
225 void CalculateTotalTicksAndSamplingRate(); | 229 void CalculateTotalTicksAndSamplingRate(); |
226 | 230 |
227 const char* title() const { return title_; } | 231 const char* title() const { return title_; } |
228 const ProfileTree* top_down() const { return &top_down_; } | 232 const ProfileTree* top_down() const { return &top_down_; } |
229 | 233 |
230 int samples_count() const { return samples_.length(); } | 234 int samples_count() const { return samples_.length(); } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 const Vector<CodeEntry*>& path, int src_line); | 336 const Vector<CodeEntry*>& path, int src_line); |
333 | 337 |
334 // Limits the number of profiles that can be simultaneously collected. | 338 // Limits the number of profiles that can be simultaneously collected. |
335 static const int kMaxSimultaneousProfiles = 100; | 339 static const int kMaxSimultaneousProfiles = 100; |
336 | 340 |
337 private: | 341 private: |
338 StringsStorage function_and_resource_names_; | 342 StringsStorage function_and_resource_names_; |
339 List<CodeEntry*> code_entries_; | 343 List<CodeEntry*> code_entries_; |
340 List<CpuProfile*> finished_profiles_; | 344 List<CpuProfile*> finished_profiles_; |
341 | 345 |
346 Isolate* isolate_; | |
347 | |
342 // Accessed by VM thread and profile generator thread. | 348 // Accessed by VM thread and profile generator thread. |
343 List<CpuProfile*> current_profiles_; | 349 List<CpuProfile*> current_profiles_; |
344 base::Semaphore current_profiles_semaphore_; | 350 base::Semaphore current_profiles_semaphore_; |
345 | 351 |
346 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); | 352 DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); |
347 }; | 353 }; |
348 | 354 |
349 | 355 |
350 class ProfileGenerator { | 356 class ProfileGenerator { |
351 public: | 357 public: |
(...skipping 21 matching lines...) Expand all Loading... | |
373 CodeEntry* unresolved_entry_; | 379 CodeEntry* unresolved_entry_; |
374 | 380 |
375 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 381 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
376 }; | 382 }; |
377 | 383 |
378 | 384 |
379 } // namespace internal | 385 } // namespace internal |
380 } // namespace v8 | 386 } // namespace v8 |
381 | 387 |
382 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ | 388 #endif // V8_PROFILER_PROFILE_GENERATOR_H_ |
OLD | NEW |