summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Memory.cpp
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2014-08-08 20:01:41 +0000
committerJim Ingham <jingham@apple.com>2014-08-08 20:01:41 +0000
commite7701fee0b9fd3867ee0dee410f58b26a50d1848 (patch)
treee44b1cfafe9c5804597b068df43802e064312919 /lldb/source/Target/Memory.cpp
parent7ee0f31a8b917add0f427ca3f47568b0b3225b7f (diff)
downloadbcm5719-llvm-e7701fee0b9fd3867ee0dee410f58b26a50d1848.tar.gz
bcm5719-llvm-e7701fee0b9fd3867ee0dee410f58b26a50d1848.zip
Fix a thinko in the memory allocator that was causing us to strand an allocation range
in all but one of the AllocatedBlocks that matched the requested permissions. Over time this would make the performance of expressions slow down considerably. Also added a little bit of logging that was helpful in resolving the issue. <rdar://problem/17954438> llvm-svn: 215239
Diffstat (limited to 'lldb/source/Target/Memory.cpp')
-rw-r--r--lldb/source/Target/Memory.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index 2dfd719ce12..b212fcd23a4 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -241,16 +241,16 @@ lldb::addr_t
AllocatedBlock::ReserveBlock (uint32_t size)
{
addr_t addr = LLDB_INVALID_ADDRESS;
+ Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
if (size <= m_byte_size)
{
const uint32_t needed_chunks = CalculateChunksNeededForSize (size);
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
if (m_offset_to_chunk_size.empty())
{
m_offset_to_chunk_size[0] = needed_chunks;
if (log)
- log->Printf ("[1] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, 0, needed_chunks, m_chunk_size);
+ log->Printf ("[1] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", this, size, size, 0, needed_chunks, m_chunk_size);
addr = m_addr;
}
else
@@ -268,7 +268,7 @@ AllocatedBlock::ReserveBlock (uint32_t size)
{
m_offset_to_chunk_size[last_offset] = needed_chunks;
if (log)
- log->Printf ("[2] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, last_offset, needed_chunks, m_chunk_size);
+ log->Printf ("[2] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks - num_chunks %lu", this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size());
addr = m_addr + last_offset;
break;
}
@@ -284,7 +284,7 @@ AllocatedBlock::ReserveBlock (uint32_t size)
{
m_offset_to_chunk_size[last_offset] = needed_chunks;
if (log)
- log->Printf ("[3] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, last_offset, needed_chunks, m_chunk_size);
+ log->Printf ("[3] AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks - num_chunks %lu", this, size, size, last_offset, needed_chunks, m_chunk_size, m_offset_to_chunk_size.size());
addr = m_addr + last_offset;
break;
}
@@ -343,9 +343,9 @@ AllocatedBlock::ReserveBlock (uint32_t size)
// return m_addr + m_chunk_size * first_chunk_idx;
// }
}
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
+
if (log)
- log->Printf ("AllocatedBlock::ReserveBlock (size = %u (0x%x)) => 0x%16.16" PRIx64, size, size, (uint64_t)addr);
+ log->Printf ("AllocatedBlock::ReserveBlock(%p) (size = %u (0x%x)) => 0x%16.16" PRIx64, this, size, size, (uint64_t)addr);
return addr;
}
@@ -362,7 +362,7 @@ AllocatedBlock::FreeBlock (addr_t addr)
}
Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
if (log)
- log->Printf ("AllocatedBlock::FreeBlock (addr = 0x%16.16" PRIx64 ") => %i", (uint64_t)addr, success);
+ log->Printf ("AllocatedBlock::FreeBlock(%p) (addr = 0x%16.16" PRIx64 ") => %i, num_chunks: %lu", this, (uint64_t)addr, success, m_offset_to_chunk_size.size());
return success;
}
@@ -436,6 +436,8 @@ AllocatedMemoryCache::AllocateMemory (size_t byte_size,
for (PermissionsToBlockMap::iterator pos = range.first; pos != range.second; ++pos)
{
addr = (*pos).second->ReserveBlock (byte_size);
+ if (addr != LLDB_INVALID_ADDRESS)
+ break;
}
if (addr == LLDB_INVALID_ADDRESS)
OpenPOWER on IntegriCloud