| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 | 107 |
| 108 const char* StringsStorage::GetCopy(const char* src) { | 108 const char* StringsStorage::GetCopy(const char* src) { |
| 109 int len = static_cast<int>(strlen(src)); | 109 int len = static_cast<int>(strlen(src)); |
| 110 Vector<char> dst = Vector<char>::New(len + 1); | 110 Vector<char> dst = Vector<char>::New(len + 1); |
| 111 OS::StrNCpy(dst, src, len); | 111 OS::StrNCpy(dst, src, len); |
| 112 dst[len] = '\0'; | 112 dst[len] = '\0'; |
| 113 uint32_t hash = | 113 uint32_t hash = |
| 114 HashSequentialString(dst.start(), len, HEAP->StringHashSeed()); | 114 HashSequentialString(dst.start(), len, HEAP->HashSeed()); |
| 115 return AddOrDisposeString(dst.start(), hash); | 115 return AddOrDisposeString(dst.start(), hash); |
| 116 } | 116 } |
| 117 | 117 |
| 118 | 118 |
| 119 const char* StringsStorage::GetFormatted(const char* format, ...) { | 119 const char* StringsStorage::GetFormatted(const char* format, ...) { |
| 120 va_list args; | 120 va_list args; |
| 121 va_start(args, format); | 121 va_start(args, format); |
| 122 const char* result = GetVFormatted(format, args); | 122 const char* result = GetVFormatted(format, args); |
| 123 va_end(args); | 123 va_end(args); |
| 124 return result; | 124 return result; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 138 | 138 |
| 139 | 139 |
| 140 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { | 140 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { |
| 141 Vector<char> str = Vector<char>::New(1024); | 141 Vector<char> str = Vector<char>::New(1024); |
| 142 int len = OS::VSNPrintF(str, format, args); | 142 int len = OS::VSNPrintF(str, format, args); |
| 143 if (len == -1) { | 143 if (len == -1) { |
| 144 DeleteArray(str.start()); | 144 DeleteArray(str.start()); |
| 145 return format; | 145 return format; |
| 146 } | 146 } |
| 147 uint32_t hash = HashSequentialString( | 147 uint32_t hash = HashSequentialString( |
| 148 str.start(), len, HEAP->StringHashSeed()); | 148 str.start(), len, HEAP->HashSeed()); |
| 149 return AddOrDisposeString(str.start(), hash); | 149 return AddOrDisposeString(str.start(), hash); |
| 150 } | 150 } |
| 151 | 151 |
| 152 | 152 |
| 153 const char* StringsStorage::GetName(String* name) { | 153 const char* StringsStorage::GetName(String* name) { |
| 154 if (name->IsString()) { | 154 if (name->IsString()) { |
| 155 int length = Min(kMaxNameSize, name->length()); | 155 int length = Min(kMaxNameSize, name->length()); |
| 156 SmartArrayPointer<char> data = | 156 SmartArrayPointer<char> data = |
| 157 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); | 157 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); |
| 158 uint32_t hash = | 158 uint32_t hash = |
| 159 HashSequentialString(*data, length, name->GetHeap()->StringHashSeed()); | 159 HashSequentialString(*data, length, name->GetHeap()->HashSeed()); |
| 160 return AddOrDisposeString(data.Detach(), hash); | 160 return AddOrDisposeString(data.Detach(), hash); |
| 161 } | 161 } |
| 162 return ""; | 162 return ""; |
| 163 } | 163 } |
| 164 | 164 |
| 165 | 165 |
| 166 const char* StringsStorage::GetName(int index) { | 166 const char* StringsStorage::GetName(int index) { |
| 167 return GetFormatted("%d", index); | 167 return GetFormatted("%d", index); |
| 168 } | 168 } |
| 169 | 169 |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 delete entries_; | 1502 delete entries_; |
| 1503 entries_ = new_entries; | 1503 entries_ = new_entries; |
| 1504 } | 1504 } |
| 1505 | 1505 |
| 1506 | 1506 |
| 1507 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { | 1507 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { |
| 1508 uint64_t id = static_cast<uint64_t>(info->GetHash()); | 1508 uint64_t id = static_cast<uint64_t>(info->GetHash()); |
| 1509 const char* label = info->GetLabel(); | 1509 const char* label = info->GetLabel(); |
| 1510 id ^= HashSequentialString(label, | 1510 id ^= HashSequentialString(label, |
| 1511 static_cast<int>(strlen(label)), | 1511 static_cast<int>(strlen(label)), |
| 1512 HEAP->StringHashSeed()); | 1512 HEAP->HashSeed()); |
| 1513 intptr_t element_count = info->GetElementCount(); | 1513 intptr_t element_count = info->GetElementCount(); |
| 1514 if (element_count != -1) | 1514 if (element_count != -1) |
| 1515 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), | 1515 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), |
| 1516 v8::internal::kZeroHashSeed); | 1516 v8::internal::kZeroHashSeed); |
| 1517 return id << 1; | 1517 return id << 1; |
| 1518 } | 1518 } |
| 1519 | 1519 |
| 1520 | 1520 |
| 1521 HeapSnapshotsCollection::HeapSnapshotsCollection() | 1521 HeapSnapshotsCollection::HeapSnapshotsCollection() |
| 1522 : is_tracking_objects_(false), | 1522 : is_tracking_objects_(false), |
| (...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3638 | 3638 |
| 3639 | 3639 |
| 3640 void HeapSnapshotJSONSerializer::SortHashMap( | 3640 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3641 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3641 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3642 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3642 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3643 sorted_entries->Add(p); | 3643 sorted_entries->Add(p); |
| 3644 sorted_entries->Sort(SortUsingEntryValue); | 3644 sorted_entries->Sort(SortUsingEntryValue); |
| 3645 } | 3645 } |
| 3646 | 3646 |
| 3647 } } // namespace v8::internal | 3647 } } // namespace v8::internal |
| OLD | NEW |