[PATCH] D52371: [sanitizer] Introduce a new SizeClassMap with minimal amount of cached entries

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 27 11:22:17 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL343246: [sanitizer] Introduce a new SizeClassMap with minimal amount of cached entries (authored by cryptoad, committed by ).

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D52371

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
  compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc


Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_size_class_map.h
@@ -232,3 +232,8 @@
 typedef SizeClassMap<3, 4, 8, 17, 128, 16> DefaultSizeClassMap;
 typedef SizeClassMap<3, 4, 8, 17, 64, 14> CompactSizeClassMap;
 typedef SizeClassMap<2, 5, 9, 16, 64, 14> VeryCompactSizeClassMap;
+
+// The following SizeClassMap only holds a way small number of cached entries,
+// allowing for denser per-class arrays, smaller memory footprint and usually
+// better performances in threaded environments.
+typedef SizeClassMap<3, 4, 8, 17, 8, 10> DenseSizeClassMap;
Index: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -89,11 +89,20 @@
   static const uptr kFlags = 0;
 };
 
+struct AP64Dense {
+  static const uptr kSpaceBeg = kAllocatorSpace;
+  static const uptr kSpaceSize = kAllocatorSize;
+  static const uptr kMetadataSize = 16;
+  typedef DenseSizeClassMap SizeClassMap;
+  typedef NoOpMapUnmapCallback MapUnmapCallback;
+  static const uptr kFlags = 0;
+};
 
 typedef SizeClassAllocator64<AP64> Allocator64;
 typedef SizeClassAllocator64<AP64Dyn> Allocator64Dynamic;
 typedef SizeClassAllocator64<AP64Compact> Allocator64Compact;
 typedef SizeClassAllocator64<AP64VeryCompact> Allocator64VeryCompact;
+typedef SizeClassAllocator64<AP64Dense> Allocator64Dense;
 #elif defined(__mips64)
 static const u64 kAddressSpaceSize = 1ULL << 40;
 #elif defined(__aarch64__)
@@ -144,6 +153,10 @@
   TestSizeClassMap<InternalSizeClassMap>();
 }
 
+TEST(SanitizerCommon, DenseSizeClassMap) {
+  TestSizeClassMap<VeryCompactSizeClassMap>();
+}
+
 template <class Allocator>
 void TestSizeClassAllocator() {
   Allocator *a = new Allocator;
@@ -234,6 +247,10 @@
 TEST(SanitizerCommon, SizeClassAllocator64VeryCompact) {
   TestSizeClassAllocator<Allocator64VeryCompact>();
 }
+
+TEST(SanitizerCommon, SizeClassAllocator64Dense) {
+  TestSizeClassAllocator<Allocator64Dense>();
+}
 #endif
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52371.167353.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/c65f0ddb/attachment.bin>


More information about the llvm-commits mailing list