| 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 return AddOrDisposeString( | 155 return AddOrDisposeString( |
| 156 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(), | 156 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(), |
| 157 name->Hash()); | 157 name->Hash()); |
| 158 } | 158 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 171 void CodeEntry::CopyData(const CodeEntry& source) { | 171 void CodeEntry::CopyData(const CodeEntry& source) { |
| 172 tag_ = source.tag_; | 172 tag_ = source.tag_; |
| 173 name_prefix_ = source.name_prefix_; | 173 name_prefix_ = source.name_prefix_; |
| 174 name_ = source.name_; | 174 name_ = source.name_; |
| 175 resource_name_ = source.resource_name_; | 175 resource_name_ = source.resource_name_; |
| 176 line_number_ = source.line_number_; | 176 line_number_ = source.line_number_; |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 uint32_t CodeEntry::GetCallUid() const { | 180 uint32_t CodeEntry::GetCallUid() const { |
| 181 uint32_t hash = ComputeIntegerHash(tag_); | 181 uint32_t hash = ComputeIntegerHash(tag_, v8::internal::kZeroHashSeed); |
| 182 if (shared_id_ != 0) { | 182 if (shared_id_ != 0) { |
| 183 hash ^= ComputeIntegerHash( | 183 hash ^= ComputeIntegerHash(static_cast<uint32_t>(shared_id_), |
| 184 static_cast<uint32_t>(shared_id_)); | 184 v8::internal::kZeroHashSeed); |
| 185 } else { | 185 } else { |
| 186 hash ^= ComputeIntegerHash( | 186 hash ^= ComputeIntegerHash( |
| 187 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_))); | 187 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_)), |
| 188 v8::internal::kZeroHashSeed); |
| 188 hash ^= ComputeIntegerHash( | 189 hash ^= ComputeIntegerHash( |
| 189 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_))); | 190 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)), |
| 191 v8::internal::kZeroHashSeed); |
| 190 hash ^= ComputeIntegerHash( | 192 hash ^= ComputeIntegerHash( |
| 191 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_))); | 193 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)), |
| 192 hash ^= ComputeIntegerHash(line_number_); | 194 v8::internal::kZeroHashSeed); |
| 195 hash ^= ComputeIntegerHash(line_number_, v8::internal::kZeroHashSeed); |
| 193 } | 196 } |
| 194 return hash; | 197 return hash; |
| 195 } | 198 } |
| 196 | 199 |
| 197 | 200 |
| 198 bool CodeEntry::IsSameAs(CodeEntry* entry) const { | 201 bool CodeEntry::IsSameAs(CodeEntry* entry) const { |
| 199 return this == entry | 202 return this == entry |
| 200 || (tag_ == entry->tag_ | 203 || (tag_ == entry->tag_ |
| 201 && shared_id_ == entry->shared_id_ | 204 && shared_id_ == entry->shared_id_ |
| 202 && (shared_id_ != 0 | 205 && (shared_id_ != 0 |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 type_(type), | 1209 type_(type), |
| 1207 title_(title), | 1210 title_(title), |
| 1208 uid_(uid), | 1211 uid_(uid), |
| 1209 root_entry_(NULL), | 1212 root_entry_(NULL), |
| 1210 gc_roots_entry_(NULL), | 1213 gc_roots_entry_(NULL), |
| 1211 natives_root_entry_(NULL), | 1214 natives_root_entry_(NULL), |
| 1212 raw_entries_(NULL), | 1215 raw_entries_(NULL), |
| 1213 entries_sorted_(false) { | 1216 entries_sorted_(false) { |
| 1214 STATIC_ASSERT( | 1217 STATIC_ASSERT( |
| 1215 sizeof(HeapGraphEdge) == | 1218 sizeof(HeapGraphEdge) == |
| 1216 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapGraphEdgeSize); // NOL
INT | 1219 SnapshotSizeConstants<kPointerSize>::kExpectedHeapGraphEdgeSize); |
| 1217 STATIC_ASSERT( | 1220 STATIC_ASSERT( |
| 1218 sizeof(HeapEntry) == | 1221 sizeof(HeapEntry) == |
| 1219 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize); // NOLINT | 1222 SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize); // NOLINT |
| 1220 } | 1223 } |
| 1221 | 1224 |
| 1222 HeapSnapshot::~HeapSnapshot() { | 1225 HeapSnapshot::~HeapSnapshot() { |
| 1223 DeleteArray(raw_entries_); | 1226 DeleteArray(raw_entries_); |
| 1224 } | 1227 } |
| 1225 | 1228 |
| 1226 | 1229 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1459 delete entries_; | 1462 delete entries_; |
| 1460 entries_ = new_entries; | 1463 entries_ = new_entries; |
| 1461 } | 1464 } |
| 1462 | 1465 |
| 1463 | 1466 |
| 1464 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { | 1467 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { |
| 1465 uint64_t id = static_cast<uint64_t>(info->GetHash()); | 1468 uint64_t id = static_cast<uint64_t>(info->GetHash()); |
| 1466 const char* label = info->GetLabel(); | 1469 const char* label = info->GetLabel(); |
| 1467 id ^= HashSequentialString(label, | 1470 id ^= HashSequentialString(label, |
| 1468 static_cast<int>(strlen(label)), | 1471 static_cast<int>(strlen(label)), |
| 1469 HEAP->StringHashSeed()); | 1472 HEAP->HashSeed()); |
| 1470 intptr_t element_count = info->GetElementCount(); | 1473 intptr_t element_count = info->GetElementCount(); |
| 1471 if (element_count != -1) | 1474 if (element_count != -1) |
| 1472 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count)); | 1475 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count), |
| 1476 v8::internal::kZeroHashSeed); |
| 1473 return id << 1; | 1477 return id << 1; |
| 1474 } | 1478 } |
| 1475 | 1479 |
| 1476 | 1480 |
| 1477 HeapSnapshotsCollection::HeapSnapshotsCollection() | 1481 HeapSnapshotsCollection::HeapSnapshotsCollection() |
| 1478 : is_tracking_objects_(false), | 1482 : is_tracking_objects_(false), |
| 1479 snapshots_uids_(HeapSnapshotsMatch), | 1483 snapshots_uids_(HeapSnapshotsMatch), |
| 1480 token_enumerator_(new TokenEnumerator()) { | 1484 token_enumerator_(new TokenEnumerator()) { |
| 1481 } | 1485 } |
| 1482 | 1486 |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 FixedArray* elements = FixedArray::cast(js_obj->elements()); | 2128 FixedArray* elements = FixedArray::cast(js_obj->elements()); |
| 2125 int length = js_obj->IsJSArray() ? | 2129 int length = js_obj->IsJSArray() ? |
| 2126 Smi::cast(JSArray::cast(js_obj)->length())->value() : | 2130 Smi::cast(JSArray::cast(js_obj)->length())->value() : |
| 2127 elements->length(); | 2131 elements->length(); |
| 2128 for (int i = 0; i < length; ++i) { | 2132 for (int i = 0; i < length; ++i) { |
| 2129 if (!elements->get(i)->IsTheHole()) { | 2133 if (!elements->get(i)->IsTheHole()) { |
| 2130 SetElementReference(js_obj, entry, i, elements->get(i)); | 2134 SetElementReference(js_obj, entry, i, elements->get(i)); |
| 2131 } | 2135 } |
| 2132 } | 2136 } |
| 2133 } else if (js_obj->HasDictionaryElements()) { | 2137 } else if (js_obj->HasDictionaryElements()) { |
| 2134 NumberDictionary* dictionary = js_obj->element_dictionary(); | 2138 SeededNumberDictionary* dictionary = js_obj->element_dictionary(); |
| 2135 int length = dictionary->Capacity(); | 2139 int length = dictionary->Capacity(); |
| 2136 for (int i = 0; i < length; ++i) { | 2140 for (int i = 0; i < length; ++i) { |
| 2137 Object* k = dictionary->KeyAt(i); | 2141 Object* k = dictionary->KeyAt(i); |
| 2138 if (dictionary->IsKey(k)) { | 2142 if (dictionary->IsKey(k)) { |
| 2139 ASSERT(k->IsNumber()); | 2143 ASSERT(k->IsNumber()); |
| 2140 uint32_t index = static_cast<uint32_t>(k->Number()); | 2144 uint32_t index = static_cast<uint32_t>(k->Number()); |
| 2141 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); | 2145 SetElementReference(js_obj, entry, index, dictionary->ValueAt(i)); |
| 2142 } | 2146 } |
| 2143 } | 2147 } |
| 2144 } | 2148 } |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3353 | 3357 |
| 3354 | 3358 |
| 3355 void HeapSnapshotJSONSerializer::SortHashMap( | 3359 void HeapSnapshotJSONSerializer::SortHashMap( |
| 3356 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3360 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
| 3357 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3361 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
| 3358 sorted_entries->Add(p); | 3362 sorted_entries->Add(p); |
| 3359 sorted_entries->Sort(SortUsingEntryValue); | 3363 sorted_entries->Sort(SortUsingEntryValue); |
| 3360 } | 3364 } |
| 3361 | 3365 |
| 3362 } } // namespace v8::internal | 3366 } } // namespace v8::internal |
| OLD | NEW |