summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-08-31 00:37:33 +0000
committerKostya Serebryany <kcc@google.com>2016-08-31 00:37:33 +0000
commitb0f82c0c385ed66f45f479f42a48bfeb71810128 (patch)
tree3e81b8793ec6bf0fa34b1eef72e214b4c1f0b8d9
parent85ef4ce805f85b52837241d051fa594486954e69 (diff)
[sanitizer] remove kBatchClassID that is not used any more; NFC
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@280185 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_local_cache.h14
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_primary32.h4
-rw-r--r--lib/sanitizer_common/sanitizer_allocator_size_class_map.h18
3 files changed, 3 insertions, 33 deletions
diff --git a/lib/sanitizer_common/sanitizer_allocator_local_cache.h b/lib/sanitizer_common/sanitizer_allocator_local_cache.h
index 4b75aafed..e1172e0c2 100644
--- a/lib/sanitizer_common/sanitizer_allocator_local_cache.h
+++ b/lib/sanitizer_common/sanitizer_allocator_local_cache.h
@@ -196,21 +196,7 @@ struct SizeClassAllocator32LocalCache {
// For small size classes we allocate batches separately.
// For large size classes we may use one of the chunks to store the batch.
// sizeof(TransferBatch) must be a power of 2 for more efficient allocation.
-
- // If kUseSeparateSizeClassForBatch is true,
- // all TransferBatch objects are allocated from kBatchClassID
- // size class (except for those that are needed for kBatchClassID itself).
- // The goal is to have TransferBatches in a totally different region of RAM
- // to improve security and allow more efficient RAM reclamation.
- // This is experimental and may currently increase memory usage by up to 3%
- // in extreme cases.
- static const bool kUseSeparateSizeClassForBatch = false;
-
static uptr SizeClassForTransferBatch(uptr class_id) {
- if (kUseSeparateSizeClassForBatch)
- return class_id == SizeClassMap::kBatchClassID
- ? 0
- : SizeClassMap::kBatchClassID;
if (Allocator::ClassIdToSize(class_id) <
TransferBatch::AllocationSizeRequiredForNElements(
TransferBatch::MaxCached(class_id)))
diff --git a/lib/sanitizer_common/sanitizer_allocator_primary32.h b/lib/sanitizer_common/sanitizer_allocator_primary32.h
index 9e23099ae..06ff815d4 100644
--- a/lib/sanitizer_common/sanitizer_allocator_primary32.h
+++ b/lib/sanitizer_common/sanitizer_allocator_primary32.h
@@ -83,9 +83,7 @@ class SizeClassAllocator32 {
SizeClassMap::kMaxNumCachedHint * sizeof(uptr));
static uptr ClassIdToSize(uptr class_id) {
- return class_id == SizeClassMap::kBatchClassID
- ? sizeof(TransferBatch)
- : SizeClassMap::Size(class_id);
+ return SizeClassMap::Size(class_id);
}
typedef SizeClassAllocator32<kSpaceBeg, kSpaceSize, kMetadataSize,
diff --git a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
index 0e29e1f8f..3fc997fad 100644
--- a/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
+++ b/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
@@ -33,9 +33,6 @@
// The actual number is computed in TransferBatch.
// - (1 << kMaxBytesCachedLog) is the maximal number of bytes per size class.
//
-// There is one extra size class kBatchClassID that is used for allocating
-// objects of TransferBatch type when kUseSeparateSizeClassForBatch is true.
-//
// Part of output of SizeClassMap::Print():
// c00 => s: 0 diff: +0 00% l 0 cached: 0 0; id 0
// c01 => s: 16 diff: +16 00% l 4 cached: 256 4096; id 1
@@ -97,8 +94,7 @@ class SizeClassMap {
static const uptr kMaxSize = 1UL << kMaxSizeLog;
static const uptr kNumClasses =
- kMidClass + ((kMaxSizeLog - kMidSizeLog) << S) + 1 + 1;
- static const uptr kBatchClassID = kNumClasses - 1;
+ kMidClass + ((kMaxSizeLog - kMidSizeLog) << S) + 1;
static const uptr kLargestClassID = kNumClasses - 2;
COMPILER_CHECK(kNumClasses >= 32 && kNumClasses <= 256);
static const uptr kNumClassesRounded =
@@ -109,8 +105,6 @@ class SizeClassMap {
static uptr Size(uptr class_id) {
if (class_id <= kMidClass)
return kMinSize * class_id;
- // Should not pass kBatchClassID here, but we should avoid a CHECK.
- if (class_id == kBatchClassID) return 0;
class_id -= kMidClass;
uptr t = kMidSize << (class_id >> S);
return t + (t >> S) * (class_id & M);
@@ -129,11 +123,6 @@ class SizeClassMap {
static uptr MaxCachedHint(uptr class_id) {
if (class_id == 0) return 0;
- // Estimate the result for kBatchClassID because this class
- // does not know the exact size of TransferBatch.
- // Moreover, we need to cache fewer batches than user chunks,
- // so this number could be small.
- if (class_id == kBatchClassID) return 8;
uptr n = (1UL << kMaxBytesCachedLog) / Size(class_id);
return Max<uptr>(1, Min(kMaxNumCachedHint, n));
}
@@ -149,8 +138,6 @@ class SizeClassMap {
uptr p = prev_s ? (d * 100 / prev_s) : 0;
uptr l = s ? MostSignificantSetBitIndex(s) : 0;
uptr cached = MaxCachedHint(i) * s;
- if (i == kBatchClassID)
- d = l = p = 0;
Printf("c%02zd => s: %zd diff: +%zd %02zd%% l %zd "
"cached: %zd %zd; id %zd\n",
i, Size(i), d, p, l, MaxCachedHint(i), cached, ClassID(s));
@@ -162,12 +149,11 @@ class SizeClassMap {
static void Validate() {
for (uptr c = 1; c < kNumClasses; c++) {
- if (c == kBatchClassID) continue;
// Printf("Validate: c%zd\n", c);
uptr s = Size(c);
CHECK_NE(s, 0U);
CHECK_EQ(ClassID(s), c);
- if (c != kBatchClassID - 1 && c != kNumClasses - 1)
+ if (c != kNumClasses - 1)
CHECK_EQ(ClassID(s + 1), c + 1);
CHECK_EQ(ClassID(s - 1), c);
if (c)