ART: Fix swap space free list
You should look for the element's size, not the freed size, when
coalescing nodes.
Bug: 18809642
Change-Id: I0c4396d52ef68f392f1e8c76a57e3fb5587b77fb
diff --git a/compiler/utils/swap_space.cc b/compiler/utils/swap_space.cc
index 44599f3..19338c0 100644
--- a/compiler/utils/swap_space.cc
+++ b/compiler/utils/swap_space.cc
@@ -142,6 +142,7 @@
LOG(ERROR) << "Unable to mmap new swap file chunk.";
LOG(ERROR) << "Current size: " << size_ << " requested: " << next_part << "/" << min_size;
LOG(ERROR) << "Free list:";
+ MutexLock lock(Thread::Current(), lock_);
DumpFreeMap(free_by_size_);
LOG(ERROR) << "In free list: " << CollectFree(free_by_start_, free_by_size_);
LOG(FATAL) << "Aborting...";
@@ -172,7 +173,7 @@
// Merge *prev with this chunk.
chunk.size += prev->size;
chunk.ptr -= prev->size;
- auto erase_pos = free_by_size_.find(FreeBySizeEntry { size, prev });
+ auto erase_pos = free_by_size_.find(FreeBySizeEntry { prev->size, prev });
DCHECK(erase_pos != free_by_size_.end());
RemoveChunk(&free_by_start_, &free_by_size_, erase_pos);
// "prev" is invalidated but "it" remains valid.
@@ -183,7 +184,7 @@
if (chunk.End() == it->Start()) {
// Merge *it with this chunk.
chunk.size += it->size;
- auto erase_pos = free_by_size_.find(FreeBySizeEntry { size, it });
+ auto erase_pos = free_by_size_.find(FreeBySizeEntry { it->size, it });
DCHECK(erase_pos != free_by_size_.end());
RemoveChunk(&free_by_start_, &free_by_size_, erase_pos);
// "it" is invalidated but we don't need it anymore.