diff options
| author | Sean Callanan <scallanan@apple.com> | 2013-05-16 17:30:37 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2013-05-16 17:30:37 +0000 |
| commit | bb77704cd164c134866c77b564389242af3510b0 (patch) | |
| tree | 197fc4883b12911bede759a9ac8b963294c51b34 /lldb/source/Expression/IRMemoryMap.cpp | |
| parent | 9daaf5775cf3157bc1942a391d366fc6ab9277ff (diff) | |
| download | bcm5719-llvm-bb77704cd164c134866c77b564389242af3510b0.tar.gz bcm5719-llvm-bb77704cd164c134866c77b564389242af3510b0.zip | |
Added a per-process cache for reserved memory
regions that aren't actually allocated in the
process. This cache is used by the expression
parser if the underlying process doesn't support
memory allocation, to avoid needless repeated
searches for unused address ranges.
Also fixed a silly bug in IRMemoryMap where it
would continue searching even after it found a
valid region.
<rdar://problem/13866629>
llvm-svn: 182028
Diffstat (limited to 'lldb/source/Expression/IRMemoryMap.cpp')
| -rw-r--r-- | lldb/source/Expression/IRMemoryMap.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp index 3b19e840367..4c4cef41572 100644 --- a/lldb/source/Expression/IRMemoryMap.cpp +++ b/lldb/source/Expression/IRMemoryMap.cpp @@ -31,19 +31,14 @@ IRMemoryMap::~IRMemoryMap () if (process_sp) { - for (AllocationMap::value_type &allocation : m_allocations) + AllocationMap::iterator iter; + + Error err; + + while ((iter = m_allocations.begin()) != m_allocations.end()) { - if (allocation.second.m_policy == eAllocationPolicyMirror || - allocation.second.m_policy == eAllocationPolicyProcessOnly || - (allocation.second.m_policy == eAllocationPolicyHostOnly && process_sp->CanJIT())) - process_sp->DeallocateMemory(allocation.second.m_process_alloc); - - if (lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)) - { - log->Printf("IRMemoryMap::~IRMemoryMap deallocated [0x%llx..0x%llx)", - (uint64_t)allocation.second.m_process_start, - (uint64_t)allocation.second.m_process_start + (uint64_t)allocation.second.m_size); - } + err.Clear(); + Free(iter->first, err); } } } @@ -68,6 +63,14 @@ IRMemoryMap::FindSpace (size_t size) return ret; } + if (process_sp) + { + ret = process_sp->GetReservationCache().Find(size); + + if (ret != LLDB_INVALID_ADDRESS) + return ret; + } + for (int iterations = 0; iterations < 16; ++iterations) { lldb::addr_t candidate = LLDB_INVALID_ADDRESS; @@ -106,6 +109,11 @@ IRMemoryMap::FindSpace (size_t size) continue; ret = candidate; + + if (process_sp) + process_sp->GetReservationCache().Reserve(candidate, size); + + return ret; } return ret; @@ -382,9 +390,14 @@ IRMemoryMap::Free (lldb::addr_t process_address, Error &error) case eAllocationPolicyHostOnly: { lldb::ProcessSP process_sp = m_process_wp.lock(); - if (process_sp && process_sp->CanJIT()) - process_sp->DeallocateMemory(allocation.m_process_alloc); // FindSpace allocated this for real - + if (process_sp) + { + if (process_sp->CanJIT()) + process_sp->DeallocateMemory(allocation.m_process_alloc); // FindSpace allocated this for real + else + process_sp->GetReservationCache().Unreserve(allocation.m_process_alloc); // FindSpace registered this memory + } + break; } case eAllocationPolicyMirror: |

