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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Provides a storage of strings allocated in C++ heap, to hold them | 62 // Provides a storage of strings allocated in C++ heap, to hold them |
63 // forever, even if they disappear from JS heap or external storage. | 63 // forever, even if they disappear from JS heap or external storage. |
64 class StringsStorage { | 64 class StringsStorage { |
65 public: | 65 public: |
66 StringsStorage(); | 66 StringsStorage(); |
67 ~StringsStorage(); | 67 ~StringsStorage(); |
68 | 68 |
69 const char* GetCopy(const char* src); | 69 const char* GetCopy(const char* src); |
70 const char* GetFormatted(const char* format, ...); | 70 const char* GetFormatted(const char* format, ...); |
71 const char* GetVFormatted(const char* format, va_list args); | 71 const char* GetVFormatted(const char* format, va_list args); |
72 const char* GetName(String* name); | 72 const char* GetName(Name* name); |
73 const char* GetName(int index); | 73 const char* GetName(int index); |
74 inline const char* GetFunctionName(String* name); | 74 inline const char* GetFunctionName(Name* name); |
75 inline const char* GetFunctionName(const char* name); | 75 inline const char* GetFunctionName(const char* name); |
76 size_t GetUsedMemorySize() const; | 76 size_t GetUsedMemorySize() const; |
77 | 77 |
78 private: | 78 private: |
79 static const int kMaxNameSize = 1024; | 79 static const int kMaxNameSize = 1024; |
80 | 80 |
81 INLINE(static bool StringsMatch(void* key1, void* key2)) { | 81 INLINE(static bool StringsMatch(void* key1, void* key2)) { |
82 return strcmp(reinterpret_cast<char*>(key1), | 82 return strcmp(reinterpret_cast<char*>(key1), |
83 reinterpret_cast<char*>(key2)) == 0; | 83 reinterpret_cast<char*>(key2)) == 0; |
84 } | 84 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 public: | 289 public: |
290 CpuProfilesCollection(); | 290 CpuProfilesCollection(); |
291 ~CpuProfilesCollection(); | 291 ~CpuProfilesCollection(); |
292 | 292 |
293 bool StartProfiling(const char* title, unsigned uid); | 293 bool StartProfiling(const char* title, unsigned uid); |
294 bool StartProfiling(String* title, unsigned uid); | 294 bool StartProfiling(String* title, unsigned uid); |
295 CpuProfile* StopProfiling(int security_token_id, | 295 CpuProfile* StopProfiling(int security_token_id, |
296 const char* title, | 296 const char* title, |
297 double actual_sampling_rate); | 297 double actual_sampling_rate); |
298 List<CpuProfile*>* Profiles(int security_token_id); | 298 List<CpuProfile*>* Profiles(int security_token_id); |
299 const char* GetName(String* name) { | 299 const char* GetName(Name* name) { |
300 return function_and_resource_names_.GetName(name); | 300 return function_and_resource_names_.GetName(name); |
301 } | 301 } |
302 const char* GetName(int args_count) { | 302 const char* GetName(int args_count) { |
303 return function_and_resource_names_.GetName(args_count); | 303 return function_and_resource_names_.GetName(args_count); |
304 } | 304 } |
305 CpuProfile* GetProfile(int security_token_id, unsigned uid); | 305 CpuProfile* GetProfile(int security_token_id, unsigned uid); |
306 bool IsLastProfile(const char* title); | 306 bool IsLastProfile(const char* title); |
307 void RemoveProfile(CpuProfile* profile); | 307 void RemoveProfile(CpuProfile* profile); |
308 bool HasDetachedProfiles() { return detached_profiles_.length() > 0; } | 308 bool HasDetachedProfiles() { return detached_profiles_.length() > 0; } |
309 | 309 |
310 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 310 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
311 String* name, String* resource_name, int line_number); | 311 Name* name, String* resource_name, int line_number); |
312 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); | 312 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); |
313 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 313 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
314 const char* name_prefix, String* name); | 314 const char* name_prefix, Name* name); |
315 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); | 315 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); |
316 CodeEntry* NewCodeEntry(int security_token_id); | 316 CodeEntry* NewCodeEntry(int security_token_id); |
317 | 317 |
318 // Called from profile generator thread. | 318 // Called from profile generator thread. |
319 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); | 319 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); |
320 | 320 |
321 // Limits the number of profiles that can be simultaneously collected. | 321 // Limits the number of profiles that can be simultaneously collected. |
322 static const int kMaxSimultaneousProfiles = 100; | 322 static const int kMaxSimultaneousProfiles = 100; |
323 | 323 |
324 private: | 324 private: |
325 const char* GetFunctionName(String* name) { | 325 const char* GetFunctionName(Name* name) { |
326 return function_and_resource_names_.GetFunctionName(name); | 326 return function_and_resource_names_.GetFunctionName(name); |
327 } | 327 } |
328 const char* GetFunctionName(const char* name) { | 328 const char* GetFunctionName(const char* name) { |
329 return function_and_resource_names_.GetFunctionName(name); | 329 return function_and_resource_names_.GetFunctionName(name); |
330 } | 330 } |
331 int GetProfileIndex(unsigned uid); | 331 int GetProfileIndex(unsigned uid); |
332 List<CpuProfile*>* GetProfilesList(int security_token_id); | 332 List<CpuProfile*>* GetProfilesList(int security_token_id); |
333 int TokenToIndex(int security_token_id); | 333 int TokenToIndex(int security_token_id); |
334 | 334 |
335 INLINE(static bool UidsMatch(void* key1, void* key2)) { | 335 INLINE(static bool UidsMatch(void* key1, void* key2)) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 388 |
389 DISALLOW_COPY_AND_ASSIGN(SampleRateCalculator); | 389 DISALLOW_COPY_AND_ASSIGN(SampleRateCalculator); |
390 }; | 390 }; |
391 | 391 |
392 | 392 |
393 class ProfileGenerator { | 393 class ProfileGenerator { |
394 public: | 394 public: |
395 explicit ProfileGenerator(CpuProfilesCollection* profiles); | 395 explicit ProfileGenerator(CpuProfilesCollection* profiles); |
396 | 396 |
397 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 397 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
398 String* name, | 398 Name* name, |
399 String* resource_name, | 399 String* resource_name, |
400 int line_number)) { | 400 int line_number)) { |
401 return profiles_->NewCodeEntry(tag, name, resource_name, line_number); | 401 return profiles_->NewCodeEntry(tag, name, resource_name, line_number); |
402 } | 402 } |
403 | 403 |
404 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 404 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
405 const char* name)) { | 405 const char* name)) { |
406 return profiles_->NewCodeEntry(tag, name); | 406 return profiles_->NewCodeEntry(tag, name); |
407 } | 407 } |
408 | 408 |
409 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 409 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
410 const char* name_prefix, | 410 const char* name_prefix, |
411 String* name)) { | 411 Name* name)) { |
412 return profiles_->NewCodeEntry(tag, name_prefix, name); | 412 return profiles_->NewCodeEntry(tag, name_prefix, name); |
413 } | 413 } |
414 | 414 |
415 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, | 415 INLINE(CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, |
416 int args_count)) { | 416 int args_count)) { |
417 return profiles_->NewCodeEntry(tag, args_count); | 417 return profiles_->NewCodeEntry(tag, args_count); |
418 } | 418 } |
419 | 419 |
420 INLINE(CodeEntry* NewCodeEntry(int security_token_id)) { | 420 INLINE(CodeEntry* NewCodeEntry(int security_token_id)) { |
421 return profiles_->NewCodeEntry(security_token_id); | 421 return profiles_->NewCodeEntry(security_token_id); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 int parent, | 916 int parent, |
917 int index, | 917 int index, |
918 Object* child); | 918 Object* child); |
919 void SetWeakReference(HeapObject* parent_obj, | 919 void SetWeakReference(HeapObject* parent_obj, |
920 int parent, | 920 int parent, |
921 int index, | 921 int index, |
922 Object* child_obj, | 922 Object* child_obj, |
923 int field_offset); | 923 int field_offset); |
924 void SetPropertyReference(HeapObject* parent_obj, | 924 void SetPropertyReference(HeapObject* parent_obj, |
925 int parent, | 925 int parent, |
926 String* reference_name, | 926 Name* reference_name, |
927 Object* child, | 927 Object* child, |
928 const char* name_format_string = NULL, | 928 const char* name_format_string = NULL, |
929 int field_offset = -1); | 929 int field_offset = -1); |
930 void SetUserGlobalReference(Object* user_global); | 930 void SetUserGlobalReference(Object* user_global); |
931 void SetRootGcRootsReference(); | 931 void SetRootGcRootsReference(); |
932 void SetGcRootsReference(VisitorSynchronization::SyncTag tag); | 932 void SetGcRootsReference(VisitorSynchronization::SyncTag tag); |
933 void SetGcSubrootReference( | 933 void SetGcSubrootReference( |
934 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child); | 934 VisitorSynchronization::SyncTag tag, bool is_weak, Object* child); |
935 const char* GetStrongGcSubrootName(Object* object); | 935 const char* GetStrongGcSubrootName(Object* object); |
936 void TagObject(Object* obj, const char* tag); | 936 void TagObject(Object* obj, const char* tag); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1095 |
1096 friend class HeapSnapshotJSONSerializerEnumerator; | 1096 friend class HeapSnapshotJSONSerializerEnumerator; |
1097 friend class HeapSnapshotJSONSerializerIterator; | 1097 friend class HeapSnapshotJSONSerializerIterator; |
1098 | 1098 |
1099 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); | 1099 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); |
1100 }; | 1100 }; |
1101 | 1101 |
1102 } } // namespace v8::internal | 1102 } } // namespace v8::internal |
1103 | 1103 |
1104 #endif // V8_PROFILE_GENERATOR_H_ | 1104 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |