diff options
author | Sean Callanan <scallanan@apple.com> | 2013-04-27 02:19:33 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2013-04-27 02:19:33 +0000 |
commit | df56540a58271deae8b0da7ccd11141f73bd0e84 (patch) | |
tree | 005507236d499afe698cbf5eb2b36e4312f89fa9 /lldb/source/Expression/IRInterpreter.cpp | |
parent | 956dca92888ebb3f770307d16f563c0e47cc0a39 (diff) | |
download | bcm5719-llvm-df56540a58271deae8b0da7ccd11141f73bd0e84.tar.gz bcm5719-llvm-df56540a58271deae8b0da7ccd11141f73bd0e84.zip |
Performance optimizations to ClangUserExpression,
mostly related to management of the stack frame
for the interpreter.
- First, if the expression can be interpreted,
allocate the stack frame in the target process
(to make sure pointers are valid) but only
read/write to the copy in the host's memory.
- Second, keep the memory allocations for the
stack frame and the materialized struct as
member variables of ClangUserExpression. This
avoids memory allocations and deallocations
each time the expression runs.
<rdar://problem/13043685>
llvm-svn: 180664
Diffstat (limited to 'lldb/source/Expression/IRInterpreter.cpp')
-rw-r--r-- | lldb/source/Expression/IRInterpreter.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp index a833e71f286..366a11526d2 100644 --- a/lldb/source/Expression/IRInterpreter.cpp +++ b/lldb/source/Expression/IRInterpreter.cpp @@ -77,42 +77,22 @@ public: size_t m_addr_byte_size; InterpreterStackFrame (DataLayout &target_data, - lldb_private::IRMemoryMap &memory_map) : + lldb_private::IRMemoryMap &memory_map, + lldb::addr_t stack_frame_bottom, + lldb::addr_t stack_frame_top) : m_target_data (target_data), m_memory_map (memory_map) { m_byte_order = (target_data.isLittleEndian() ? lldb::eByteOrderLittle : lldb::eByteOrderBig); m_addr_byte_size = (target_data.getPointerSize(0)); - - m_frame_size = 512 * 1024; - - lldb_private::Error alloc_error; - - m_frame_process_address = memory_map.Malloc(m_frame_size, - m_addr_byte_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - lldb_private::IRMemoryMap::eAllocationPolicyMirror, - alloc_error); - - if (alloc_error.Success()) - { - m_stack_pointer = m_frame_process_address + m_frame_size; - } - else - { - m_frame_process_address = LLDB_INVALID_ADDRESS; - m_stack_pointer = LLDB_INVALID_ADDRESS; - } + + m_frame_process_address = stack_frame_bottom; + m_frame_size = stack_frame_top - stack_frame_bottom; + m_stack_pointer = stack_frame_top; } ~InterpreterStackFrame () { - if (m_frame_process_address != LLDB_INVALID_ADDRESS) - { - lldb_private::Error free_error; - m_memory_map.Free(m_frame_process_address, free_error); - m_frame_process_address = LLDB_INVALID_ADDRESS; - } } void Jump (const BasicBlock *bb) @@ -535,7 +515,9 @@ IRInterpreter::Interpret (llvm::Module &module, llvm::Function &function, llvm::ArrayRef<lldb::addr_t> args, lldb_private::IRMemoryMap &memory_map, - lldb_private::Error &error) + lldb_private::Error &error, + lldb::addr_t stack_frame_bottom, + lldb::addr_t stack_frame_top) { lldb_private::Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -553,7 +535,7 @@ IRInterpreter::Interpret (llvm::Module &module, DataLayout data_layout(&module); - InterpreterStackFrame frame(data_layout, memory_map); + InterpreterStackFrame frame(data_layout, memory_map, stack_frame_bottom, stack_frame_top); if (frame.m_frame_process_address == LLDB_INVALID_ADDRESS) { |