diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-01-11 11:39:59 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-01-11 11:39:59 +0000 |
commit | f79419553c6a636a4304cd40bda3e6d581e6137e (patch) | |
tree | b0655e458551c2fee47e4e4070eb2d52bd403f3b /lib/sanitizer_common/sanitizer_quarantine.h | |
parent | 9327e78387122fbb04e3126f2fff721ed784aa51 (diff) |
asan: prevent inlining of cold function
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172197 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_quarantine.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_quarantine.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lib/sanitizer_common/sanitizer_quarantine.h b/lib/sanitizer_common/sanitizer_quarantine.h index f256d99a7..c06d518f0 100644 --- a/lib/sanitizer_common/sanitizer_quarantine.h +++ b/lib/sanitizer_common/sanitizer_quarantine.h @@ -63,22 +63,8 @@ class Quarantine { SpinMutexLock l(&cache_mutex_); cache_.Transfer(c); } - if (cache_.Size() > max_size_ && recycle_mutex_.TryLock()) { - Cache tmp; - { - SpinMutexLock l(&cache_mutex_); - while (cache_.Size() > max_size_) { - QuarantineBatch *b = cache_.DequeueBatch(); - tmp.EnqueueBatch(b); - } - } - recycle_mutex_.Unlock(); - while (QuarantineBatch *b = tmp.DequeueBatch()) { - for (uptr i = 0; i < b->count; i++) - cb.Recycle((Node*)b->batch[i]); - cb.Deallocate(b); - } - } + if (cache_.Size() > max_size_ && recycle_mutex_.TryLock()) + Recycle(cb); } private: @@ -92,6 +78,23 @@ class Quarantine { SpinMutex recycle_mutex_; Cache cache_; char pad2_[kCacheLineSize]; + + void NOINLINE Recycle(Callback cb) { + Cache tmp; + { + SpinMutexLock l(&cache_mutex_); + while (cache_.Size() > min_size_) { + QuarantineBatch *b = cache_.DequeueBatch(); + tmp.EnqueueBatch(b); + } + } + recycle_mutex_.Unlock(); + while (QuarantineBatch *b = tmp.DequeueBatch()) { + for (uptr i = 0; i < b->count; i++) + cb.Recycle((Node*)b->batch[i]); + cb.Deallocate(b); + } + } }; // Per-thread cache of memory blocks. |