mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73725 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b2c0fe4d93
commit
e454067f97
@ -32,7 +32,7 @@ namespace {
|
|||||||
static void print(const Value* P) { cerr << *P; }
|
static void print(const Value* P) { cerr << *P; }
|
||||||
};
|
};
|
||||||
|
|
||||||
ManagedStatic<sys::RWMutex> LeakDetectorLock;
|
ManagedStatic<sys::SmartRWMutex<true> > LeakDetectorLock;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct VISIBILITY_HIDDEN LeakDetectorImpl {
|
struct VISIBILITY_HIDDEN LeakDetectorImpl {
|
||||||
@ -54,41 +54,26 @@ namespace {
|
|||||||
// immediately, it is added to the CachedValue Value. If it is
|
// immediately, it is added to the CachedValue Value. If it is
|
||||||
// immediately removed, no set search need be performed.
|
// immediately removed, no set search need be performed.
|
||||||
void addGarbage(const T* o) {
|
void addGarbage(const T* o) {
|
||||||
if (llvm_is_multithreaded()) {
|
sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
|
||||||
sys::ScopedWriter Writer(&*LeakDetectorLock);
|
if (Cache) {
|
||||||
if (Cache) {
|
assert(Ts.count(Cache) == 0 && "Object already in set!");
|
||||||
assert(Ts.count(Cache) == 0 && "Object already in set!");
|
Ts.insert(Cache);
|
||||||
Ts.insert(Cache);
|
|
||||||
}
|
|
||||||
Cache = o;
|
|
||||||
} else {
|
|
||||||
if (Cache) {
|
|
||||||
assert(Ts.count(Cache) == 0 && "Object already in set!");
|
|
||||||
Ts.insert(Cache);
|
|
||||||
}
|
|
||||||
Cache = o;
|
|
||||||
}
|
}
|
||||||
|
Cache = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeGarbage(const T* o) {
|
void removeGarbage(const T* o) {
|
||||||
if (llvm_is_multithreaded()) {
|
sys::SmartScopedWriter<true> Writer(&*LeakDetectorLock);
|
||||||
sys::ScopedWriter Writer(&*LeakDetectorLock);
|
if (o == Cache)
|
||||||
if (o == Cache)
|
Cache = 0; // Cache hit
|
||||||
Cache = 0; // Cache hit
|
else
|
||||||
else
|
Ts.erase(o);
|
||||||
Ts.erase(o);
|
|
||||||
} else {
|
|
||||||
if (o == Cache)
|
|
||||||
Cache = 0; // Cache hit
|
|
||||||
else
|
|
||||||
Ts.erase(o);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasGarbage(const std::string& Message) {
|
bool hasGarbage(const std::string& Message) {
|
||||||
addGarbage(0); // Flush the Cache
|
addGarbage(0); // Flush the Cache
|
||||||
|
|
||||||
if (llvm_is_multithreaded()) LeakDetectorLock->reader_acquire();
|
sys::SmartScopedReader<true> Reader(&*LeakDetectorLock);
|
||||||
assert(Cache == 0 && "No value should be cached anymore!");
|
assert(Cache == 0 && "No value should be cached anymore!");
|
||||||
|
|
||||||
if (!Ts.empty()) {
|
if (!Ts.empty()) {
|
||||||
@ -101,11 +86,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
cerr << '\n';
|
cerr << '\n';
|
||||||
|
|
||||||
if (llvm_is_multithreaded()) LeakDetectorLock->reader_release();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llvm_is_multithreaded()) LeakDetectorLock->reader_release();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user