mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 03:56:16 +08:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user