| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 const char* StringsStorage::GetCopy(const char* src) { | 109 const char* StringsStorage::GetCopy(const char* src) { |
| 110 int len = static_cast<int>(strlen(src)); | 110 int len = static_cast<int>(strlen(src)); |
| 111 Vector<char> dst = Vector<char>::New(len + 1); | 111 Vector<char> dst = Vector<char>::New(len + 1); |
| 112 OS::StrNCpy(dst, src, len); | 112 OS::StrNCpy(dst, src, len); |
| 113 dst[len] = '\0'; | 113 dst[len] = '\0'; |
| 114 uint32_t hash = | 114 uint32_t hash = |
| 115 HashSequentialString(dst.start(), len, HEAP->HashSeed()); | 115 StringHasher::HashSequentialString(dst.start(), len, HEAP->HashSeed()); |
| 116 return AddOrDisposeString(dst.start(), hash); | 116 return AddOrDisposeString(dst.start(), hash); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 const char* StringsStorage::GetFormatted(const char* format, ...) { | 120 const char* StringsStorage::GetFormatted(const char* format, ...) { |
| 121 va_list args; | 121 va_list args; |
| 122 va_start(args, format); | 122 va_start(args, format); |
| 123 const char* result = GetVFormatted(format, args); | 123 const char* result = GetVFormatted(format, args); |
| 124 va_end(args); | 124 va_end(args); |
| 125 return result; | 125 return result; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { | 141 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { |
| 142 Vector<char> str = Vector<char>::New(1024); | 142 Vector<char> str = Vector<char>::New(1024); |
| 143 int len = OS::VSNPrintF(str, format, args); | 143 int len = OS::VSNPrintF(str, format, args); |
| 144 if (len == -1) { | 144 if (len == -1) { |
| 145 DeleteArray(str.start()); | 145 DeleteArray(str.start()); |
| 146 return format; | 146 return format; |
| 147 } | 147 } |
| 148 uint32_t hash = HashSequentialString( | 148 uint32_t hash = StringHasher::HashSequentialString( |
| 149 str.start(), len, HEAP->HashSeed()); | 149 str.start(), len, HEAP->HashSeed()); |
| 150 return AddOrDisposeString(str.start(), hash); | 150 return AddOrDisposeString(str.start(), hash); |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 const char* StringsStorage::GetName(String* name) { | 154 const char* StringsStorage::GetName(String* name) { |
| 155 if (name->IsString()) { | 155 if (name->IsString()) { |
| 156 int length = Min(kMaxNameSize, name->length()); | 156 int length = Min(kMaxNameSize, name->length()); |
| 157 SmartArrayPointer<char> data = | 157 SmartArrayPointer<char> data = |
| 158 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); | 158 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, 0, length); |
| 159 uint32_t hash = | 159 uint32_t hash = StringHasher::HashSequentialString( |
| 160 HashSequentialString(*data, length, name->GetHeap()->HashSeed()); | 160 *data, length, name->GetHeap()->HashSeed()); |
| 161 return AddOrDisposeString(data.Detach(), hash); | 161 return AddOrDisposeString(data.Detach(), hash); |
| 162 } | 162 } |
| 163 return ""; | 163 return ""; |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 const char* StringsStorage::GetName(int index) { | 167 const char* StringsStorage::GetName(int index) { |
| 168 return GetFormatted("%d", index); | 168 return GetFormatted("%d", index); |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 } | 1444 } |
| 1445 entries_.Rewind(first_free_entry); | 1445 entries_.Rewind(first_free_entry); |
| 1446 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 == | 1446 ASSERT(static_cast<uint32_t>(entries_.length()) - 1 == |
| 1447 entries_map_.occupancy()); | 1447 entries_map_.occupancy()); |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 | 1450 |
| 1451 SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { | 1451 SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { |
| 1452 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash()); | 1452 SnapshotObjectId id = static_cast<SnapshotObjectId>(info->GetHash()); |
| 1453 const char* label = info->GetLabel(); | 1453 const char* label = info->GetLabel(); |
| 1454 id ^= HashSequentialString(label, | 1454 id ^= StringHasher::HashSequentialString(label, |
| 1455 static_cast<int>(strlen(label)), | 1455 static_cast<int>(strlen(label)), |
| 1456 HEAP->HashSeed()); | 1456 HEAP->HashSeed()); |
| 1457 intptr_t element_count = info->GetElementCount(); | 1457 intptr_t element_count = info->GetElementCount(); |
| 1458 if (element_count != -1) | 1458 if (element_count != -1) |
| 1459 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), | 1459 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), |
| 1460 v8::internal::kZeroHashSeed); | 1460 v8::internal::kZeroHashSeed); |
| 1461 return id << 1; | 1461 return id << 1; |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 | 1464 |
| 1465 size_t HeapObjectsMap::GetUsedMemorySize() const { | 1465 size_t HeapObjectsMap::GetUsedMemorySize() const { |
| 1466 return | 1466 return |
| (...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2933 private: | 2933 private: |
| 2934 bool disposed_; | 2934 bool disposed_; |
| 2935 intptr_t hash_; | 2935 intptr_t hash_; |
| 2936 const char* label_; | 2936 const char* label_; |
| 2937 }; | 2937 }; |
| 2938 | 2938 |
| 2939 | 2939 |
| 2940 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo( | 2940 NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo( |
| 2941 const char* label) { | 2941 const char* label) { |
| 2942 const char* label_copy = collection_->names()->GetCopy(label); | 2942 const char* label_copy = collection_->names()->GetCopy(label); |
| 2943 uint32_t hash = HashSequentialString(label_copy, | 2943 uint32_t hash = StringHasher::HashSequentialString( |
| 2944 static_cast<int>(strlen(label_copy)), | 2944 label_copy, |
| 2945 HEAP->HashSeed()); | 2945 static_cast<int>(strlen(label_copy)), |
| 2946 HEAP->HashSeed()); |
| 2946 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy), | 2947 HashMap::Entry* entry = native_groups_.Lookup(const_cast<char*>(label_copy), |
| 2947 hash, true); | 2948 hash, true); |
| 2948 if (entry->value == NULL) { | 2949 if (entry->value == NULL) { |
| 2949 entry->value = new NativeGroupRetainedObjectInfo(label); | 2950 entry->value = new NativeGroupRetainedObjectInfo(label); |
| 2950 } | 2951 } |
| 2951 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value); | 2952 return static_cast<NativeGroupRetainedObjectInfo*>(entry->value); |
| 2952 } | 2953 } |
| 2953 | 2954 |
| 2954 | 2955 |
| 2955 void NativeObjectsExplorer::SetNativeRootReference( | 2956 void NativeObjectsExplorer::SetNativeRootReference( |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3579 | 3580 |
| 3580 | 3581 |
| 3581 void HeapSnapshotJSONSerializer::SortHashMap( | 3582 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3582 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3583 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3583 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3584 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3584 sorted_entries->Add(p); | 3585 sorted_entries->Add(p); |
| 3585 sorted_entries->Sort(SortUsingEntryValue); | 3586 sorted_entries->Sort(SortUsingEntryValue); |
| 3586 } | 3587 } |
| 3587 | 3588 |
| 3588 } } // namespace v8::internal | 3589 } } // namespace v8::internal |
| OLD | NEW |