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.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139983 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Utility/SharingPtr.cpp b/source/Utility/SharingPtr.cpp
index 88c103a..3ee0128 100644
--- a/source/Utility/SharingPtr.cpp
+++ b/source/Utility/SharingPtr.cpp
@@ -14,40 +14,42 @@
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
+