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

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

Issue 9124004: Backport hash collision workaround to 3.6. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.6/
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 DeleteArray(reinterpret_cast<const char*>(p->value)); 103 DeleteArray(reinterpret_cast<const char*>(p->value));
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 = HashSequentialString(dst.start(), len); 113 uint32_t hash =
114 HashSequentialString(dst.start(), len, HEAP->StringHashSeed());
114 return AddOrDisposeString(dst.start(), hash); 115 return AddOrDisposeString(dst.start(), hash);
115 } 116 }
116 117
117 118
118 const char* StringsStorage::GetFormatted(const char* format, ...) { 119 const char* StringsStorage::GetFormatted(const char* format, ...) {
119 va_list args; 120 va_list args;
120 va_start(args, format); 121 va_start(args, format);
121 const char* result = GetVFormatted(format, args); 122 const char* result = GetVFormatted(format, args);
122 va_end(args); 123 va_end(args);
123 return result; 124 return result;
(...skipping 12 matching lines...) Expand all
136 } 137 }
137 138
138 139
139 const char* StringsStorage::GetVFormatted(const char* format, va_list args) { 140 const char* StringsStorage::GetVFormatted(const char* format, va_list args) {
140 Vector<char> str = Vector<char>::New(1024); 141 Vector<char> str = Vector<char>::New(1024);
141 int len = OS::VSNPrintF(str, format, args); 142 int len = OS::VSNPrintF(str, format, args);
142 if (len == -1) { 143 if (len == -1) {
143 DeleteArray(str.start()); 144 DeleteArray(str.start());
144 return format; 145 return format;
145 } 146 }
146 uint32_t hash = HashSequentialString(str.start(), len); 147 uint32_t hash = HashSequentialString(
148 str.start(), len, HEAP->StringHashSeed());
147 return AddOrDisposeString(str.start(), hash); 149 return AddOrDisposeString(str.start(), hash);
148 } 150 }
149 151
150 152
151 const char* StringsStorage::GetName(String* name) { 153 const char* StringsStorage::GetName(String* name) {
152 if (name->IsString()) { 154 if (name->IsString()) {
153 return AddOrDisposeString( 155 return AddOrDisposeString(
154 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(), 156 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach(),
155 name->Hash()); 157 name->Hash());
156 } 158 }
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 raw_entry, AddressHash(reinterpret_cast<Address>(raw_entry))); 1457 raw_entry, AddressHash(reinterpret_cast<Address>(raw_entry)));
1456 } 1458 }
1457 delete entries_; 1459 delete entries_;
1458 entries_ = new_entries; 1460 entries_ = new_entries;
1459 } 1461 }
1460 1462
1461 1463
1462 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) { 1464 uint64_t HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) {
1463 uint64_t id = static_cast<uint64_t>(info->GetHash()); 1465 uint64_t id = static_cast<uint64_t>(info->GetHash());
1464 const char* label = info->GetLabel(); 1466 const char* label = info->GetLabel();
1465 id ^= HashSequentialString(label, static_cast<int>(strlen(label))); 1467 id ^= HashSequentialString(label,
1468 static_cast<int>(strlen(label)),
1469 HEAP->StringHashSeed());
1466 intptr_t element_count = info->GetElementCount(); 1470 intptr_t element_count = info->GetElementCount();
1467 if (element_count != -1) 1471 if (element_count != -1)
1468 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count)); 1472 id ^= ComputeIntegerHash(static_cast<uint32_t>(element_count));
1469 return id << 1; 1473 return id << 1;
1470 } 1474 }
1471 1475
1472 1476
1473 HeapSnapshotsCollection::HeapSnapshotsCollection() 1477 HeapSnapshotsCollection::HeapSnapshotsCollection()
1474 : is_tracking_objects_(false), 1478 : is_tracking_objects_(false),
1475 snapshots_uids_(HeapSnapshotsMatch), 1479 snapshots_uids_(HeapSnapshotsMatch),
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after
3349 3353
3350 3354
3351 void HeapSnapshotJSONSerializer::SortHashMap( 3355 void HeapSnapshotJSONSerializer::SortHashMap(
3352 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 3356 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
3353 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 3357 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
3354 sorted_entries->Add(p); 3358 sorted_entries->Add(p);
3355 sorted_entries->Sort(SortUsingEntryValue); 3359 sorted_entries->Sort(SortUsingEntryValue);
3356 } 3360 }
3357 3361
3358 } } // namespace v8::internal 3362 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects-inl.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698