Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/profile-generator.h

Issue 3769007: New Heap profiler: add dumping HeapNumbers and InternalFields to snapshot. (Closed)
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8-profiler.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 61
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* GetName(String* name); 69 const char* GetName(String* name);
70 const char* GetName(int index);
70 inline const char* GetFunctionName(String* name); 71 inline const char* GetFunctionName(String* name);
71 inline const char* GetFunctionName(const char* name); 72 inline const char* GetFunctionName(const char* name);
72 73
73 private: 74 private:
74 INLINE(static bool StringsMatch(void* key1, void* key2)) { 75 INLINE(static bool StringsMatch(void* key1, void* key2)) {
75 return strcmp(reinterpret_cast<char*>(key1), 76 return strcmp(reinterpret_cast<char*>(key1),
76 reinterpret_cast<char*>(key2)) == 0; 77 reinterpret_cast<char*>(key2)) == 0;
77 } 78 }
78 79
79 // Mapping of strings by String::Hash to const char* strings. 80 // Mapping of strings by String::Hash to const char* strings.
80 HashMap names_; 81 HashMap names_;
82 // Mapping from ints to char* strings.
83 List<char*> index_names_;
81 84
82 DISALLOW_COPY_AND_ASSIGN(StringsStorage); 85 DISALLOW_COPY_AND_ASSIGN(StringsStorage);
83 }; 86 };
84 87
85 88
86 class CodeEntry { 89 class CodeEntry {
87 public: 90 public:
88 explicit INLINE(CodeEntry(int security_token_id)); 91 explicit INLINE(CodeEntry(int security_token_id));
89 // CodeEntry doesn't own name strings, just references them. 92 // CodeEntry doesn't own name strings, just references them.
90 INLINE(CodeEntry(Logger::LogEventsAndTags tag, 93 INLINE(CodeEntry(Logger::LogEventsAndTags tag,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 280
278 bool StartProfiling(const char* title, unsigned uid); 281 bool StartProfiling(const char* title, unsigned uid);
279 bool StartProfiling(String* title, unsigned uid); 282 bool StartProfiling(String* title, unsigned uid);
280 CpuProfile* StopProfiling(int security_token_id, 283 CpuProfile* StopProfiling(int security_token_id,
281 const char* title, 284 const char* title,
282 double actual_sampling_rate); 285 double actual_sampling_rate);
283 List<CpuProfile*>* Profiles(int security_token_id); 286 List<CpuProfile*>* Profiles(int security_token_id);
284 const char* GetName(String* name) { 287 const char* GetName(String* name) {
285 return function_and_resource_names_.GetName(name); 288 return function_and_resource_names_.GetName(name);
286 } 289 }
290 const char* GetName(int args_count) {
291 return function_and_resource_names_.GetName(args_count);
292 }
287 CpuProfile* GetProfile(int security_token_id, unsigned uid); 293 CpuProfile* GetProfile(int security_token_id, unsigned uid);
288 bool IsLastProfile(const char* title); 294 bool IsLastProfile(const char* title);
289 295
290 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, 296 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
291 String* name, String* resource_name, int line_number); 297 String* name, String* resource_name, int line_number);
292 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); 298 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
293 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, 299 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
294 const char* name_prefix, String* name); 300 const char* name_prefix, String* name);
295 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count); 301 CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, int args_count);
296 CodeEntry* NewCodeEntry(int security_token_id); 302 CodeEntry* NewCodeEntry(int security_token_id);
297 303
298 // Called from profile generator thread. 304 // Called from profile generator thread.
299 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path); 305 void AddPathToCurrentProfiles(const Vector<CodeEntry*>& path);
300 306
301 // Limits the number of profiles that can be simultaneously collected. 307 // Limits the number of profiles that can be simultaneously collected.
302 static const int kMaxSimultaneousProfiles = 100; 308 static const int kMaxSimultaneousProfiles = 100;
303 309
304 private: 310 private:
305 const char* GetName(int args_count);
306 const char* GetFunctionName(String* name) { 311 const char* GetFunctionName(String* name) {
307 return function_and_resource_names_.GetFunctionName(name); 312 return function_and_resource_names_.GetFunctionName(name);
308 } 313 }
309 const char* GetFunctionName(const char* name) { 314 const char* GetFunctionName(const char* name) {
310 return function_and_resource_names_.GetFunctionName(name); 315 return function_and_resource_names_.GetFunctionName(name);
311 } 316 }
312 List<CpuProfile*>* GetProfilesList(int security_token_id); 317 List<CpuProfile*>* GetProfilesList(int security_token_id);
313 int TokenToIndex(int security_token_id); 318 int TokenToIndex(int security_token_id);
314 319
315 INLINE(static bool UidsMatch(void* key1, void* key2)) { 320 INLINE(static bool UidsMatch(void* key1, void* key2)) {
316 return key1 == key2; 321 return key1 == key2;
317 } 322 }
318 323
319 StringsStorage function_and_resource_names_; 324 StringsStorage function_and_resource_names_;
320 // Mapping from args_count (int) to char* strings.
321 List<char*> args_count_names_;
322 List<CodeEntry*> code_entries_; 325 List<CodeEntry*> code_entries_;
323 List<List<CpuProfile*>* > profiles_by_token_; 326 List<List<CpuProfile*>* > profiles_by_token_;
324 // Mapping from profiles' uids to indexes in the second nested list 327 // Mapping from profiles' uids to indexes in the second nested list
325 // of profiles_by_token_. 328 // of profiles_by_token_.
326 HashMap profiles_uids_; 329 HashMap profiles_uids_;
327 330
328 // Accessed by VM thread and profile generator thread. 331 // Accessed by VM thread and profile generator thread.
329 List<CpuProfile*> current_profiles_; 332 List<CpuProfile*> current_profiles_;
330 Semaphore* current_profiles_semaphore_; 333 Semaphore* current_profiles_semaphore_;
331 334
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // 499 //
497 class HeapEntry BASE_EMBEDDED { 500 class HeapEntry BASE_EMBEDDED {
498 public: 501 public:
499 enum Type { 502 enum Type {
500 kInternal = v8::HeapGraphNode::kInternal, 503 kInternal = v8::HeapGraphNode::kInternal,
501 kArray = v8::HeapGraphNode::kArray, 504 kArray = v8::HeapGraphNode::kArray,
502 kString = v8::HeapGraphNode::kString, 505 kString = v8::HeapGraphNode::kString,
503 kObject = v8::HeapGraphNode::kObject, 506 kObject = v8::HeapGraphNode::kObject,
504 kCode = v8::HeapGraphNode::kCode, 507 kCode = v8::HeapGraphNode::kCode,
505 kClosure = v8::HeapGraphNode::kClosure, 508 kClosure = v8::HeapGraphNode::kClosure,
506 kRegExp = v8::HeapGraphNode::kRegExp 509 kRegExp = v8::HeapGraphNode::kRegExp,
510 kHeapNumber = v8::HeapGraphNode::kHeapNumber
507 }; 511 };
508 512
509 HeapEntry() { } 513 HeapEntry() { }
510 void Init(HeapSnapshot* snapshot, 514 void Init(HeapSnapshot* snapshot,
511 Type type, 515 Type type,
512 const char* name, 516 const char* name,
513 uint64_t id, 517 uint64_t id,
514 int self_size, 518 int self_size,
515 int children_count, 519 int children_count,
516 int retainers_count); 520 int retainers_count);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 822
819 bool is_tracking_objects() { return is_tracking_objects_; } 823 bool is_tracking_objects() { return is_tracking_objects_; }
820 824
821 HeapSnapshot* NewSnapshot( 825 HeapSnapshot* NewSnapshot(
822 HeapSnapshot::Type type, const char* name, unsigned uid); 826 HeapSnapshot::Type type, const char* name, unsigned uid);
823 void SnapshotGenerationFinished() { ids_.SnapshotGenerationFinished(); } 827 void SnapshotGenerationFinished() { ids_.SnapshotGenerationFinished(); }
824 List<HeapSnapshot*>* snapshots() { return &snapshots_; } 828 List<HeapSnapshot*>* snapshots() { return &snapshots_; }
825 HeapSnapshot* GetSnapshot(unsigned uid); 829 HeapSnapshot* GetSnapshot(unsigned uid);
826 830
827 const char* GetName(String* name) { return names_.GetName(name); } 831 const char* GetName(String* name) { return names_.GetName(name); }
832 const char* GetName(int index) { return names_.GetName(index); }
828 const char* GetFunctionName(String* name) { 833 const char* GetFunctionName(String* name) {
829 return names_.GetFunctionName(name); 834 return names_.GetFunctionName(name);
830 } 835 }
831 836
832 TokenEnumerator* token_enumerator() { return token_enumerator_; } 837 TokenEnumerator* token_enumerator() { return token_enumerator_; }
833 838
834 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); } 839 uint64_t GetObjectId(Address addr) { return ids_.FindObject(addr); }
835 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); } 840 void ObjectMoveEvent(Address from, Address to) { ids_.MoveObject(from, to); }
836 841
837 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1, 842 HeapSnapshotsDiff* CompareSnapshots(HeapSnapshot* snapshot1,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 void GenerateSnapshot(); 947 void GenerateSnapshot();
943 948
944 private: 949 private:
945 HeapEntry* GetEntry(Object* obj); 950 HeapEntry* GetEntry(Object* obj);
946 int GetGlobalSecurityToken(); 951 int GetGlobalSecurityToken();
947 int GetObjectSecurityToken(HeapObject* obj); 952 int GetObjectSecurityToken(HeapObject* obj);
948 void ExtractReferences(HeapObject* obj); 953 void ExtractReferences(HeapObject* obj);
949 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry); 954 void ExtractClosureReferences(JSObject* js_obj, HeapEntry* entry);
950 void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry); 955 void ExtractPropertyReferences(JSObject* js_obj, HeapEntry* entry);
951 void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry); 956 void ExtractElementReferences(JSObject* js_obj, HeapEntry* entry);
957 void ExtractInternalReferences(JSObject* js_obj, HeapEntry* entry);
952 void SetClosureReference(HeapObject* parent_obj, 958 void SetClosureReference(HeapObject* parent_obj,
953 HeapEntry* parent, 959 HeapEntry* parent,
954 String* reference_name, 960 String* reference_name,
955 Object* child); 961 Object* child);
956 void SetElementReference(HeapObject* parent_obj, 962 void SetElementReference(HeapObject* parent_obj,
957 HeapEntry* parent, 963 HeapEntry* parent,
958 int index, 964 int index,
959 Object* child); 965 Object* child);
960 void SetInternalReference(HeapObject* parent_obj, 966 void SetInternalReference(HeapObject* parent_obj,
961 HeapEntry* parent, 967 HeapEntry* parent,
962 const char* reference_name, 968 const char* reference_name,
963 Object* child); 969 Object* child);
970 void SetInternalReference(HeapObject* parent_obj,
971 HeapEntry* parent,
972 int index,
973 Object* child);
964 void SetPropertyReference(HeapObject* parent_obj, 974 void SetPropertyReference(HeapObject* parent_obj,
965 HeapEntry* parent, 975 HeapEntry* parent,
966 String* reference_name, 976 String* reference_name,
967 Object* child); 977 Object* child);
968 void SetRootReference(Object* child); 978 void SetRootReference(Object* child);
969 979
970 HeapSnapshot* snapshot_; 980 HeapSnapshot* snapshot_;
971 HeapSnapshotsCollection* collection_; 981 HeapSnapshotsCollection* collection_;
972 // Mapping from HeapObject* pointers to HeapEntry* pointers. 982 // Mapping from HeapObject* pointers to HeapEntry* pointers.
973 HeapEntriesMap entries_; 983 HeapEntriesMap entries_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 friend class HeapSnapshotJSONSerializerIterator; 1035 friend class HeapSnapshotJSONSerializerIterator;
1026 1036
1027 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer); 1037 DISALLOW_COPY_AND_ASSIGN(HeapSnapshotJSONSerializer);
1028 }; 1038 };
1029 1039
1030 } } // namespace v8::internal 1040 } } // namespace v8::internal
1031 1041
1032 #endif // ENABLE_LOGGING_AND_PROFILING 1042 #endif // ENABLE_LOGGING_AND_PROFILING
1033 1043
1034 #endif // V8_PROFILE_GENERATOR_H_ 1044 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « include/v8-profiler.h ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698