Commit 34c372d8 authored by loislo@chromium.org's avatar loislo@chromium.org

Fix for HeapSnapshotAddressReuse test case.

BUG=V8:2189
TEST=HeapSnapshotAddressReuse

Review URL: https://chromiumcodereview.appspot.com/12320039

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13721 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d01fced7
...@@ -404,21 +404,33 @@ void HeapObjectsMap::MoveObject(Address from, Address to) { ...@@ -404,21 +404,33 @@ void HeapObjectsMap::MoveObject(Address from, Address to) {
ASSERT(from != NULL); ASSERT(from != NULL);
if (from == to) return; if (from == to) return;
void* from_value = entries_map_.Remove(from, AddressHash(from)); void* from_value = entries_map_.Remove(from, AddressHash(from));
if (from_value == NULL) return; if (from_value == NULL) {
int from_entry_info_index = // It may occur that some untracked object moves to an address X and there
static_cast<int>(reinterpret_cast<intptr_t>(from_value)); // is a tracked object at that address. In this case we should remove the
entries_.at(from_entry_info_index).addr = to; // entry as we know that the object has died.
HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true); void* to_value = entries_map_.Remove(to, AddressHash(to));
if (to_entry->value != NULL) { if (to_value != NULL) {
int to_entry_info_index = int to_entry_info_index =
static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value)); static_cast<int>(reinterpret_cast<intptr_t>(to_value));
// Without this operation we will have two EntryInfo's with the same entries_.at(to_entry_info_index).addr = NULL;
// value in addr field. It is bad because later at RemoveDeadEntries }
// one of this entry will be removed with the corresponding entries_map_ } else {
// entry. HashMap::Entry* to_entry = entries_map_.Lookup(to, AddressHash(to), true);
entries_.at(to_entry_info_index).addr = NULL; if (to_entry->value != NULL) {
} // We found the existing entry with to address for an old object.
to_entry->value = reinterpret_cast<void*>(from_entry_info_index); // Without this operation we will have two EntryInfo's with the same
// value in addr field. It is bad because later at RemoveDeadEntries
// one of this entry will be removed with the corresponding entries_map_
// entry.
int to_entry_info_index =
static_cast<int>(reinterpret_cast<intptr_t>(to_entry->value));
entries_.at(to_entry_info_index).addr = NULL;
}
int from_entry_info_index =
static_cast<int>(reinterpret_cast<intptr_t>(from_value));
entries_.at(from_entry_info_index).addr = to;
to_entry->value = from_value;
}
} }
......
...@@ -394,8 +394,7 @@ TEST(HeapSnapshotAddressReuse) { ...@@ -394,8 +394,7 @@ TEST(HeapSnapshotAddressReuse) {
if (id < maxId1) if (id < maxId1)
++wrong_count; ++wrong_count;
} }
// FIXME: Object ids should be unique but it is not so at the moment. CHECK_EQ(0, wrong_count);
CHECK_NE(0, wrong_count);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment