summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-10-21 08:36:10 +0000
committerKostya Serebryany <kcc@google.com>2013-10-21 08:36:10 +0000
commitb773785a593592020a449dfcfe65bd4e4f93fe71 (patch)
tree014670c6f45eed14ba7aef75c4d31a598568552d
parent88033d7a97d2bbf78e16e47975f9ff8ff814a87b (diff)
downloadbcm5719-llvm-b773785a593592020a449dfcfe65bd4e4f93fe71.tar.gz
bcm5719-llvm-b773785a593592020a449dfcfe65bd4e4f93fe71.zip
[asan] count the size of QuarantineBatch in the total Quarantine size; make QuarantineBatch fit into 8K, fix a MSVC compile warning
llvm-svn: 193072
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
index b21ab23a7b4..db4eb74505f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h
@@ -26,13 +26,15 @@ namespace __sanitizer {
template<typename Node> class QuarantineCache;
struct QuarantineBatch {
- static const uptr kSize = 1024;
+ static const uptr kSize = 1021;
QuarantineBatch *next;
uptr size;
uptr count;
void *batch[kSize];
};
+COMPILER_CHECK(sizeof(QuarantineBatch) <= (1 << 13)); // 8Kb.
+
// The callback interface is:
// void Callback::Recycle(Node *ptr);
// void *cb.Allocate(uptr size);
@@ -123,8 +125,10 @@ class QuarantineCache {
}
void Enqueue(Callback cb, void *ptr, uptr size) {
- if (list_.empty() || list_.back()->count == QuarantineBatch::kSize)
+ if (list_.empty() || list_.back()->count == QuarantineBatch::kSize) {
AllocBatch(cb);
+ size += sizeof(QuarantineBatch); // Count the batch in Quarantine size.
+ }
QuarantineBatch *b = list_.back();
b->batch[b->count++] = ptr;
b->size += size;
@@ -147,9 +151,7 @@ class QuarantineCache {
return 0;
QuarantineBatch *b = list_.front();
list_.pop_front();
- // FIXME: should probably add SizeSub method?
- // See https://code.google.com/p/thread-sanitizer/issues/detail?id=20
- SizeAdd(0 - b->size);
+ SizeSub(b->size);
return b;
}
@@ -160,6 +162,9 @@ class QuarantineCache {
void SizeAdd(uptr add) {
atomic_store(&size_, Size() + add, memory_order_relaxed);
}
+ void SizeSub(uptr sub) {
+ atomic_store(&size_, Size() - sub, memory_order_relaxed);
+ }
NOINLINE QuarantineBatch* AllocBatch(Callback cb) {
QuarantineBatch *b = (QuarantineBatch *)cb.Allocate(sizeof(*b));
OpenPOWER on IntegriCloud