mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
<rdar://problem/13643315>
Fixed performance issues that arose after changing SBTarget, SBProcess, SBThread and SBFrame over to using a std::shared_ptr to a ExecutionContextRef. The ExecutionContextRef doesn't store a std::weak_ptr to a stack frame because stack frames often get replaced with new version, so it held onto a StackID object that would allow us to ask the thread each time for the frame for the StackID. The linear function was too slow for large recursive stacks. We also fixed an issue where anytime the std::shared_ptr<ExecutionContextRef> in any SBTarget, SBProcess, SBThread objects was turned into an ExecutionContext object, it would try to resolve all items in the ExecutionContext which are shared pointers. Even if the StackID in the ExecutionContextRef was invalid, it was looking through all frames in every thread. This causes a lot of unnecessary frame accesses. llvm-svn: 182627
This commit is contained in:
@@ -381,7 +381,9 @@ public:
|
||||
virtual lldb::StackFrameSP
|
||||
GetFrameWithStackID (const StackID &stack_id)
|
||||
{
|
||||
return GetStackFrameList()->GetFrameWithStackID (stack_id);
|
||||
if (stack_id.IsValid())
|
||||
return GetStackFrameList()->GetFrameWithStackID (stack_id);
|
||||
return lldb::StackFrameSP();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
||||
@@ -806,9 +806,12 @@ ExecutionContextRef::GetThreadSP () const
|
||||
lldb::StackFrameSP
|
||||
ExecutionContextRef::GetFrameSP () const
|
||||
{
|
||||
lldb::ThreadSP thread_sp (GetThreadSP());
|
||||
if (thread_sp)
|
||||
return thread_sp->GetFrameWithStackID (m_stack_id);
|
||||
if (m_stack_id.IsValid())
|
||||
{
|
||||
lldb::ThreadSP thread_sp (GetThreadSP());
|
||||
if (thread_sp)
|
||||
return thread_sp->GetFrameWithStackID (m_stack_id);
|
||||
}
|
||||
return lldb::StackFrameSP();
|
||||
}
|
||||
|
||||
|
||||
@@ -595,19 +595,42 @@ StackFrameList::GetFrameWithConcreteFrameIndex (uint32_t unwind_idx)
|
||||
return frame_sp;
|
||||
}
|
||||
|
||||
static bool
|
||||
CompareStackID (const StackFrameSP &stack_sp, const StackID &stack_id)
|
||||
{
|
||||
return stack_sp->GetStackID() < stack_id;
|
||||
}
|
||||
|
||||
StackFrameSP
|
||||
StackFrameList::GetFrameWithStackID (const StackID &stack_id)
|
||||
{
|
||||
uint32_t frame_idx = 0;
|
||||
StackFrameSP frame_sp;
|
||||
do
|
||||
|
||||
if (stack_id.IsValid())
|
||||
{
|
||||
frame_sp = GetFrameAtIndex (frame_idx);
|
||||
if (frame_sp && frame_sp->GetStackID() == stack_id)
|
||||
break;
|
||||
frame_idx++;
|
||||
Mutex::Locker locker (m_mutex);
|
||||
uint32_t frame_idx = 0;
|
||||
// Do a binary search in case the stack frame is already in our cache
|
||||
collection::const_iterator begin = m_frames.begin();
|
||||
collection::const_iterator end = m_frames.end();
|
||||
if (begin != end)
|
||||
{
|
||||
collection::const_iterator pos = std::lower_bound (begin, end, stack_id, CompareStackID);
|
||||
if (pos != end && (*pos)->GetStackID() == stack_id)
|
||||
return *pos;
|
||||
|
||||
if (m_frames.back()->GetStackID() < stack_id)
|
||||
frame_idx = m_frames.size();
|
||||
}
|
||||
do
|
||||
{
|
||||
frame_sp = GetFrameAtIndex (frame_idx);
|
||||
if (frame_sp && frame_sp->GetStackID() == stack_id)
|
||||
break;
|
||||
frame_idx++;
|
||||
}
|
||||
while (frame_sp);
|
||||
}
|
||||
while (frame_sp);
|
||||
return frame_sp;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user