Skip to content

Commit

Permalink
codingstyle -imsi
Browse files Browse the repository at this point in the history
Signed-off-by: Hyeonggon Yoo <[email protected]>
  • Loading branch information
hygoni committed Apr 14, 2024
1 parent d5550a2 commit 8dffb06
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 28 deletions.
4 changes: 3 additions & 1 deletion compiler-rt/lib/asan/asan_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ struct AsanMapUnmapCallback {
void OnMap(uptr p, uptr size) const;
void OnMapSecondary(uptr p, uptr size, uptr user_begin, uptr user_size) const;
void OnUnmap(uptr p, uptr size) const;
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

#if SANITIZER_CAN_USE_ALLOCATOR64
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/dfsan/dfsan_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ struct DFsanMapUnmapCallback {
OnMap(p, size);
}
void OnUnmap(uptr p, uptr size) const { dfsan_set_label(0, (void *)p, size); }
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

#if defined(__aarch64__)
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/hwasan/hwasan_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ struct HwasanMapUnmapCallback {
// Make it accessible with zero-tagged pointer.
TagMemory(p, size, 0);
}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

static const uptr kMaxAllowedMallocSize = 1UL << 40; // 1T
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/memprof/memprof_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ struct MemprofMapUnmapCallback {
OnMap(p, size);
}
void OnUnmap(uptr p, uptr size) const;
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

constexpr uptr kAllocatorSpace = 0x600000000000ULL;
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/msan/msan_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ struct MsanMapUnmapCallback {
ReleaseMemoryPagesToOS(origin_p, origin_p + size);
}
}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

#if defined(__mips64)
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/plsan/plsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ void InitializeMetadataTable() {

// assume 48 bits of virtual address space
uptr table_size = 1LL << (48 - __builtin_ctz(page_size));
metadata_table = (uptr *)MmapNoReserveOrDie(table_size * sizeof(void *),
"Metadata table");
metadata_table =
(uptr *)MmapNoReserveOrDie(table_size * sizeof(void *), "Metadata table");
}

void InitializeLocalVariableTLS() {
Expand Down
17 changes: 9 additions & 8 deletions compiler-rt/lib/plsan/plsan_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ void GetAllocatorCacheRange(uptr *begin, uptr *end) {
*end = *begin + sizeof(AllocatorCache);
}

Metadata *GetMetadata(const void *p) {
return __plsan_metadata_lookup(p);
}
Metadata *GetMetadata(const void *p) { return __plsan_metadata_lookup(p); }

void IncRefCount(Metadata *metadata) {
if (!metadata)
Expand Down Expand Up @@ -168,7 +166,8 @@ static void RegisterAllocation(const StackTrace *stack, void *p, uptr size) {
: __lsan::kDirectlyLeaked);
RunMallocHooks(p, size);
if (!allocator.FromPrimary(p)) {
__plsan_set_metabase(reinterpret_cast<uptr>(p), reinterpret_cast<uptr>(m), size);
__plsan_set_metabase(reinterpret_cast<uptr>(p), reinterpret_cast<uptr>(m),
size);
}
}

Expand Down Expand Up @@ -295,11 +294,13 @@ struct Metadata *__plsan_metadata_lookup(const void *p) {
uptr metabase = entry & ~(kUserMapSize - 1);
__sanitizer::u32 object_size = entry & (kUserMapSize - 1);
// XXX: integer division is costly
__sanitizer::u32 chunk_idx = (addr % ((object_size / kMetadataSize) * kUserMapSize)) / object_size;
struct Metadata *m = reinterpret_cast<Metadata *>(metabase - (1 + chunk_idx) * kMetadataSize);
__sanitizer::u32 chunk_idx =
(addr % ((object_size / kMetadataSize) * kUserMapSize)) / object_size;
struct Metadata *m = reinterpret_cast<Metadata *>(
metabase - (1 + chunk_idx) * kMetadataSize);
// p = allocator.GetBlockBegin(p);
// struct Metadata *n = reinterpret_cast<Metadata *>(allocator.GetMetaData(p));
// CHECK(m = n);
// struct Metadata *n = reinterpret_cast<Metadata
// *>(allocator.GetMetaData(p)); CHECK(m = n);
return m;
}

Expand Down
14 changes: 9 additions & 5 deletions compiler-rt/lib/plsan/plsan_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,22 @@ struct PlsanMapUnmapCallback {
void OnMapSecondary(uptr p, uptr size, uptr user_begin,
uptr user_size) const {}
void OnUnmap(uptr p, uptr size) const {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {
__plsan_set_metabase(user_chunk_base, user_map_size, meta_chunk_base, object_size);
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {
__plsan_set_metabase(user_chunk_base, user_map_size, meta_chunk_base,
object_size);
}
};

#if SANITIZER_APPLE
const uptr kAllocatorSpace = 0x600000000000ULL;
// const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
#else
const uptr kAllocatorSpace = 0x500000000000ULL;
// const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
const uptr kAllocatorSize = 0x2000000000ULL; // 128G.
#endif
const uptr kAllocatorEnd = kAllocatorSpace + kAllocatorSize;

Expand All @@ -96,7 +99,8 @@ struct AP64 {
static const uptr kSpaceSize = kAllocatorSize; // 4T.
// VeryCompactSizeClassMap restricts the primary allocator's
// max allocation size under 2^15, which metadata table depends on.
// This is kind of workaround to make max allocation to be equal to kMetaMapSize and kUserMapSize
// This is kind of workaround to make max allocation to be equal to
// kMetaMapSize and kUserMapSize
typedef __sanitizer::SizeClassMap<2, 5, 9, 15, 64, 14> SizeClassMap;
static const uptr kMetadataSize = sizeof(Metadata);
using AddressSpaceView = LocalAddressSpaceView;
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/sanitizer_common/sanitizer_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ struct NoOpMapUnmapCallback {
void OnMapSecondary(uptr p, uptr size, uptr user_begin,
uptr user_size) const {}
void OnUnmap(uptr p, uptr size) const {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

#include "sanitizer_allocator_size_class_map.h"
Expand Down
10 changes: 4 additions & 6 deletions compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,12 +806,10 @@ class SizeClassAllocator64 {
// Round down to chunksPerMap
const uptr chunksPerMap = kMetaMapSize / kMetadataSize;
first_chunk_idx = (first_chunk_idx / chunksPerMap) * chunksPerMap;
const uptr meta_chunk_begin = GetMetadataEnd(region_beg) - (first_chunk_idx) * kMetadataSize;
MapUnmapCallback().OnMetaChunkInit(user_chunk_begin,
user_map_size,
meta_chunk_begin,
0,
size);
const uptr meta_chunk_begin =
GetMetadataEnd(region_beg) - (first_chunk_idx)*kMetadataSize;
MapUnmapCallback().OnMetaChunkInit(user_chunk_begin, user_map_size,
meta_chunk_begin, 0, size);
stat->Add(AllocatorStatMapped, user_map_size);
region->mapped_user += user_map_size;
}
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/tsan/rtl/tsan_mman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ struct MapUnmapCallback {
uptr p_meta = (uptr)MemToMeta(p);
ReleaseMemoryPagesToOS(p_meta, p_meta + size / kMetaRatio);
}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size, uptr meta_chunk_base, uptr meta_map_size, uptr object_size) {}
void OnMetaChunkInit(uptr user_chunk_base, uptr user_map_size,
uptr meta_chunk_base, uptr meta_map_size,
uptr object_size) {}
};

static char allocator_placeholder[sizeof(Allocator)] ALIGNED(64);
Expand Down

0 comments on commit 8dffb06

Please sign in to comment.