Convert lldb::ModuleSP to use an instrusive ref counted pointer.

We had some cases where getting the shared pointer for a module from
the global module list was causing a performance issue when debugging
with DWARF in .o files. Now that the module uses intrusive ref counts,
we can easily convert any pointer to a shared pointer.

llvm-svn: 139983
This commit is contained in:
Greg Clayton
2011-09-17 06:21:20 +00:00
parent 5631ebce5e
commit 747bcb03d2
22 changed files with 415 additions and 95 deletions

View File

@@ -14,40 +14,42 @@ namespace lldb_private {
namespace imp
{
template <class T>
inline T
increment(T& t)
{
return __sync_add_and_fetch(&t, 1);
}
template <class T>
inline T
decrement(T& t)
{
return __sync_add_and_fetch(&t, -1);
}
shared_count::~shared_count()
{
}
void
shared_count::add_shared()
{
increment(shared_owners_);
}
void
shared_count::release_shared()
{
if (decrement(shared_owners_) == -1)
template <class T>
inline T
increment(T& t)
{
on_zero_shared();
delete this;
return __sync_add_and_fetch(&t, 1);
}
template <class T>
inline T
decrement(T& t)
{
return __sync_add_and_fetch(&t, -1);
}
shared_count::~shared_count()
{
}
void
shared_count::add_shared()
{
increment(shared_owners_);
}
void
shared_count::release_shared()
{
if (decrement(shared_owners_) == -1)
{
on_zero_shared();
delete this;
}
}
}
} // imp
} // namespace lldb