[llvm-commits] [compiler-rt] r172197 - /compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h

Dmitry Vyukov dvyukov at google.com
Fri Jan 11 03:39:59 PST 2013


Author: dvyukov
Date: Fri Jan 11 05:39:59 2013
New Revision: 172197

URL: http://llvm.org/viewvc/llvm-project?rev=172197&view=rev
Log:
asan: prevent inlining of cold function

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h?rev=172197&r1=172196&r2=172197&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_quarantine.h Fri Jan 11 05:39:59 2013
@@ -63,22 +63,8 @@
       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 @@
   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.





More information about the llvm-commits mailing list