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

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: Created 7 years, 10 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 // This fact is using in MoveObject method. 392 // This fact is using in MoveObject method.
393 entries_.Add(EntryInfo(0, NULL, 0)); 393 entries_.Add(EntryInfo(0, NULL, 0));
394 } 394 }
395 395
396 396
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) {
yurys 2013/02/21 15:26:43 Is it possible that an object is allocated (not mo
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 // We don't know the object that may occupy the place of a known object.
yurys 2013/02/21 15:26:43 I'd rephrase like this: "It may occur that some u
409 static_cast<int>(reinterpret_cast<intptr_t>(from_value)); 409 // In that case we need to remove the entry for this died known object.
yurys 2013/02/21 15:26:43 died -> dead
410 entries_.at(from_entry_info_index).addr = to; 410 void* to_value = entries_map_.Remove(to, AddressHash(to));
411 HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true); 411 if (to_value != NULL) {
412 if (to_entry->value != NULL) { 412 int to_entry_info_index =
413 int to_entry_info_index = 413 static_cast<int>(reinterpret_cast<intptr_t>(to_value));
414 entries_.at(to_entry_info_index).addr = NULL;
415 }
416 } else {
417 HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true);
418 if (to_entry->value != NULL) {
419 // We found the entry with to address for an old object.
yurys 2013/02/21 15:26:43 the entry -> existing entry
420 // Without this operation we will have two EntryInfo's with the same
421 // value in addr field. It is bad because later at RemoveDeadEntries
422 // one of this entry will be removed with the corresponding entries_map_
423 // entry.
424 int to_entry_info_index =
414 static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value)); 425 static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value));
415 // Without this operation we will have two EntryInfo's with the same 426 entries_.at(to_entry_info_index).addr = NULL;
416 // value in addr field. It is bad because later at RemoveDeadEntries 427 int from_entry_info_index =
417 // one of this entry will be removed with the corresponding entries_map_ 428 static_cast<int>(reinterpret_cast<intptr_t>(from_value));
418 // entry. 429 entries_.at(from_entry_info_index).addr = to;
419 entries_.at(to_entry_info_index).addr = NULL; 430 to_entry->value = reinterpret_cast<void*>(from_entry_info_index);
yurys 2013/02/21 15:26:43 to_entry->value = from_value; ?
431 }
420 } 432 }
421 to_entry->value = reinterpret_cast<void*>(from_entry_info_index);
422 } 433 }
423 434
424 435
425 SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) { 436 SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) {
426 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false); 437 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false);
427 if (entry == NULL) return 0; 438 if (entry == NULL) return 0;
428 int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 439 int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
429 EntryInfo& entry_info = entries_.at(entry_index); 440 EntryInfo& entry_info = entries_.at(entry_index);
430 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy()); 441 ASSERT(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy());
431 return entry_info.id; 442 return entry_info.id;
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 2693
2683 2694
2684 void HeapSnapshotJSONSerializer::SortHashMap( 2695 void HeapSnapshotJSONSerializer::SortHashMap(
2685 HashMap* map, List<HashMap::Entry*>* sorted_entries) { 2696 HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2686 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) 2697 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2687 sorted_entries->Add(p); 2698 sorted_entries->Add(p);
2688 sorted_entries->Sort(SortUsingEntryValue); 2699 sorted_entries->Sort(SortUsingEntryValue);
2689 } 2700 }
2690 2701
2691 } } // namespace v8::internal 2702 } } // 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