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

Side by Side Diff: src/heap-snapshot-generator.cc

Issue 12320039: Fix for HeapSnapshotAddressReuse test case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: unnecessary change was removed Created 7 years, 9 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
« no previous file with comments | « no previous file | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 void HeapObjectsMap::SnapshotGenerationFinished() { 397 void HeapObjectsMap::SnapshotGenerationFinished() {
398 RemoveDeadEntries(); 398 RemoveDeadEntries();
399 } 399 }
400 400
401 401
402 void HeapObjectsMap::MoveObject(Address from, Address to) { 402 void HeapObjectsMap::MoveObject(Address from, Address to) {
403 ASSERT(to != NULL); 403 ASSERT(to != NULL);
404 ASSERT(from != NULL); 404 ASSERT(from != NULL);
405 if (from == to) return; 405 if (from == to) return;
406 void* from_value = entries_map_.Remove(from, AddressHash(from)); 406 void* from_value = entries_map_.Remove(from, AddressHash(from));
407 if (from_value == NULL) return; 407 if (from_value == NULL) {
408 int from_entry_info_index = 408 // It may occur that some untracked object moves to an address X and there
409 static_cast<int>(reinterpret_cast<intptr_t>(from_value)); 409 // is a tracked object at that address. In this case we should remove the
410 entries_.at(from_entry_info_index).addr = to; 410 // entry as we know that the object has died.
411 HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true); 411 void* to_value = entries_map_.Remove(to, AddressHash(to));
412 if (to_entry->value != NULL) { 412 if (to_value != NULL) {
413 int to_entry_info_index = 413 int to_entry_info_index =
414 static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value)); 414 static_cast<int>(reinterpret_cast<intptr_t>(to_value));
415 // Without this operation we will have two EntryInfo's with the same 415 entries_.at(to_entry_info_index).addr = NULL;
416 // value in addr field. It is bad because later at RemoveDeadEntries 416 }
417 // one of this entry will be removed with the corresponding entries_map_ 417 } else {
418 // entry. 418 HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true);
419 entries_.at(to_entry_info_index).addr = NULL; 419 if (to_entry->value != NULL) {
420 // We found the existing entry with to address for an old object.
421 // Without this operation we will have two EntryInfo's with the same
422 // value in addr field. It is bad because later at RemoveDeadEntries
423 // one of this entry will be removed with the corresponding entries_map_
424 // entry.
425 int to_entry_info_index =
426 static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value));
427 entries_.at(to_entry_info_index).addr = NULL;
428 }
429 int from_entry_info_index =
430 static_cast<int>(reinterpret_cast<intptr_t>(from_value));
431 entries_.at(from_entry_info_index).addr = to;
432 to_entry->value = from_value;
420 } 433 }
421 to_entry->value = reinterpret_cast<void*>(from_entry_info_index);
422 } 434 }
423 435
424 436
425 SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) { 437 SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) {
426 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false); 438 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false);
427 if (entry == NULL) return 0; 439 if (entry == NULL) return 0;
428 int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 440 int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
429 EntryInfo& entry_info = entries_.at(entry_index); 441 EntryInfo& entry_info = entries_.at(entry_index);
430 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); 442 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy());
431 return entry_info.id; 443 return entry_info.id;
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 2694
2683 2695
2684 void HeapSnapshotJSONSerializer::SortHashMap( 2696 void HeapSnapshotJSONSerializer::SortHashMap(
2685 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2697 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2686 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2698 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2687 sorted_entries->Add(p); 2699 sorted_entries->Add(p);
2688 sorted_entries->Sort(SortUsingEntryValue); 2700 sorted_entries->Sort(SortUsingEntryValue);
2689 } 2701 }
2690 2702
2691 } } // namespace v8::internal 2703 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698