Changeset 99374 in webkit for trunk/Source/JavaScriptCore/heap/VTableSpectrum.cpp
- Timestamp:
- Nov 6, 2011, 3:39:12 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/heap/VTableSpectrum.cpp
r95901 r99374 50 50 void VTableSpectrum::countVPtr(void* vTablePointer) 51 51 { 52 std::pair<HashMap<void*, unsigned long>::iterator, bool> result = m_map.add(vTablePointer, 1); 53 if (!result.second) 54 result.first->second++; 52 add(vTablePointer); 55 53 } 56 54 … … 60 58 } 61 59 62 struct VTableAndCount {63 void* vtable;64 unsigned long count;65 66 VTableAndCount() { }67 68 VTableAndCount(void* vtable, unsigned long count)69 : vtable(vtable)70 , count(count)71 {72 }73 74 bool operator<(const VTableAndCount& other) const75 {76 if (count != other.count)77 return count < other.count;78 return vtable > other.vtable; // this results in lower-addressed vtables being printed first79 }80 };81 82 60 void VTableSpectrum::dump(FILE* output, const char* comment) 83 61 { 84 62 fprintf(output, "%s:\n", comment); 85 63 86 HashMap<void*, unsigned long>::iterator begin = m_map.begin(); 87 HashMap<void*, unsigned long>::iterator end = m_map.end(); 88 89 Vector<VTableAndCount, 0> list; 90 91 for (HashMap<void*, unsigned long>::iterator iter = begin; iter != end; ++iter) 92 list.append(VTableAndCount(iter->first, iter->second)); 93 94 std::sort(list.begin(), list.end()); 64 Vector<KeyAndCount> list = buildList(); 95 65 96 66 for (size_t index = list.size(); index-- > 0;) { 97 VTableAndCount item = list.at(index);67 KeyAndCount item = list.at(index); 98 68 #if PLATFORM(MAC) 99 69 Dl_info info; 100 if (dladdr(item. vtable, &info)) {70 if (dladdr(item.key, &info)) { 101 71 char* findResult = strrchr(info.dli_fname, '/'); 102 72 const char* strippedFileName; … … 107 77 strippedFileName = info.dli_fname; 108 78 109 fprintf(output, " %s:%s(%p): %lu\n", strippedFileName, info.dli_sname, item. vtable, item.count);79 fprintf(output, " %s:%s(%p): %lu\n", strippedFileName, info.dli_sname, item.key, item.count); 110 80 continue; 111 81 } 112 82 #endif 113 fprintf(output, " %p: %lu\n", item. vtable, item.count);83 fprintf(output, " %p: %lu\n", item.key, item.count); 114 84 } 115 85
Note:
See TracChangeset
for help on using the changeset viewer.