diff options
author | Alex Shlyapnikov <alekseys@google.com> | 2017-01-09 23:49:15 +0000 |
---|---|---|
committer | Alex Shlyapnikov <alekseys@google.com> | 2017-01-09 23:49:15 +0000 |
commit | bc4ff1f4efc5ee08802c01377fe033f551ab173b (patch) | |
tree | 51242266ebc69c2ab18b18c25aac87f57ec9d859 | |
parent | cab0bf6bb6a02eb2104918059a09154e967fbfdf (diff) |
Bypass quarantine when quarantine size is set ot zero.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291510 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/sanitizer_common/sanitizer_quarantine.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_quarantine.h b/lib/sanitizer_common/sanitizer_quarantine.h index 63953d29c..1a0d9545b 100644 --- a/lib/sanitizer_common/sanitizer_quarantine.h +++ b/lib/sanitizer_common/sanitizer_quarantine.h @@ -49,6 +49,10 @@ class Quarantine { } void Init(uptr size, uptr cache_size) { + // Thread local quarantine size can be zero only when global quarantine size + // is zero (it allows us to perform just one atomic read per Put() call). + CHECK((size == 0 && cache_size == 0) || cache_size != 0); + atomic_store(&max_size_, size, memory_order_relaxed); atomic_store(&min_size_, size / 10 * 9, memory_order_relaxed); // 90% of max size. @@ -61,8 +65,15 @@ class Quarantine { } void Put(Cache *c, Callback cb, Node *ptr, uptr size) { - c->Enqueue(cb, ptr, size); - if (c->Size() > GetCacheSize()) + uptr cache_size = GetCacheSize(); + if (cache_size) { + c->Enqueue(cb, ptr, size); + } else { + // cache_size == 0 only when size == 0 (see Init). + cb.Recycle(ptr); + } + // Check cache size anyway to accommodate for runtime cache_size change. + if (c->Size() > cache_size) Drain(c, cb); } @@ -207,6 +218,7 @@ class QuarantineCache { return b; } }; + } // namespace __sanitizer #endif // SANITIZER_QUARANTINE_H |