forked from OSchip/llvm-project
Replace some #ifdef(s) with plain if(s).
llvm-svn: 151526
This commit is contained in:
parent
93887631d9
commit
d84e16e6a3
|
@ -46,24 +46,17 @@ static const size_t kMinAllocSize = REDZONE * 2;
|
||||||
static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
|
static const uint64_t kMaxAvailableRam = 128ULL << 30; // 128G
|
||||||
static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M
|
static const size_t kMaxThreadLocalQuarantine = 1 << 20; // 1M
|
||||||
|
|
||||||
#if ASAN_LOW_MEMORY == 1
|
static const size_t kMinMmapSize = (ASAN_LOW_MEMORY) ? 4UL << 17 : 4UL << 20;
|
||||||
static const size_t kMinMmapSize = 4UL << 17; // 128K
|
static const size_t kMaxSizeForThreadLocalFreeList =
|
||||||
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 15; // 32K
|
(ASAN_LOW_MEMORY) ? 1 << 15 : 1 << 17;
|
||||||
#else
|
|
||||||
static const size_t kMinMmapSize = 4UL << 20; // 4M
|
|
||||||
static const size_t kMaxSizeForThreadLocalFreeList = 1 << 17; // 128K
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Size classes less than kMallocSizeClassStep are powers of two.
|
// Size classes less than kMallocSizeClassStep are powers of two.
|
||||||
// All other size classes are multiples of kMallocSizeClassStep.
|
// All other size classes are multiples of kMallocSizeClassStep.
|
||||||
static const size_t kMallocSizeClassStepLog = 26;
|
static const size_t kMallocSizeClassStepLog = 26;
|
||||||
static const size_t kMallocSizeClassStep = 1UL << kMallocSizeClassStepLog;
|
static const size_t kMallocSizeClassStep = 1UL << kMallocSizeClassStepLog;
|
||||||
|
|
||||||
#if __WORDSIZE == 32
|
static const size_t kMaxAllowedMallocSize =
|
||||||
static const size_t kMaxAllowedMallocSize = 3UL << 30; // 3G
|
(__WORDSIZE == 32) ? 3UL << 30 : 8UL << 30;
|
||||||
#else
|
|
||||||
static const size_t kMaxAllowedMallocSize = 8UL << 30; // 8G
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAligned(uintptr_t a, uintptr_t alignment) {
|
static inline bool IsAligned(uintptr_t a, uintptr_t alignment) {
|
||||||
return (a & (alignment - 1)) == 0;
|
return (a & (alignment - 1)) == 0;
|
||||||
|
|
|
@ -129,6 +129,12 @@ extern "C" void* _ReturnAddress(void);
|
||||||
# define ASAN_FLEXIBLE_MAPPING_AND_OFFSET 0
|
# define ASAN_FLEXIBLE_MAPPING_AND_OFFSET 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// If set, values like allocator chunk size, as well as defaults for some flags
|
||||||
|
// will be changed towards less memory overhead.
|
||||||
|
#ifndef ASAN_LOW_MEMORY
|
||||||
|
# define ASAN_LOW_MEMORY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// All internal functions in asan reside inside the __asan namespace
|
// All internal functions in asan reside inside the __asan namespace
|
||||||
// to avoid namespace collisions with the user programs.
|
// to avoid namespace collisions with the user programs.
|
||||||
// Seperate namespace also makes it simpler to distinguish the asan run-time
|
// Seperate namespace also makes it simpler to distinguish the asan run-time
|
||||||
|
|
|
@ -410,15 +410,8 @@ void __asan_init() {
|
||||||
|
|
||||||
FLAG_v = IntFlagValue(options, "verbosity=", 0);
|
FLAG_v = IntFlagValue(options, "verbosity=", 0);
|
||||||
|
|
||||||
#if ASAN_LOW_MEMORY == 1
|
FLAG_redzone = IntFlagValue(options, "redzone=",
|
||||||
FLAG_quarantine_size =
|
(ASAN_LOW_MEMORY) ? 64 : 128);
|
||||||
IntFlagValue(options, "quarantine_size=", 1UL << 24); // 16M
|
|
||||||
FLAG_redzone = IntFlagValue(options, "redzone=", 64);
|
|
||||||
#else
|
|
||||||
FLAG_quarantine_size =
|
|
||||||
IntFlagValue(options, "quarantine_size=", 1UL << 28); // 256M
|
|
||||||
FLAG_redzone = IntFlagValue(options, "redzone=", 128);
|
|
||||||
#endif
|
|
||||||
CHECK(FLAG_redzone >= 32);
|
CHECK(FLAG_redzone >= 32);
|
||||||
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
|
CHECK((FLAG_redzone & (FLAG_redzone - 1)) == 0);
|
||||||
|
|
||||||
|
@ -443,6 +436,9 @@ void __asan_init() {
|
||||||
Atexit(asan_atexit);
|
Atexit(asan_atexit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLAG_quarantine_size = IntFlagValue(options, "quarantine_size=",
|
||||||
|
(ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28);
|
||||||
|
|
||||||
// interceptors
|
// interceptors
|
||||||
InitializeAsanInterceptors();
|
InitializeAsanInterceptors();
|
||||||
|
|
||||||
|
|
|
@ -453,11 +453,7 @@ static void MallocStress(size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(AddressSanitizer, MallocStressTest) {
|
TEST(AddressSanitizer, MallocStressTest) {
|
||||||
#if ASAN_LOW_MEMORY == 1
|
MallocStress((ASAN_LOW_MEMORY) ? 20000 : 200000);
|
||||||
MallocStress(20000);
|
|
||||||
#else
|
|
||||||
MallocStress(200000);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TestLargeMalloc(size_t size) {
|
static void TestLargeMalloc(size_t size) {
|
||||||
|
@ -489,13 +485,11 @@ TEST(AddressSanitizer, HugeMallocTest) {
|
||||||
|
|
||||||
TEST(AddressSanitizer, ThreadedMallocStressTest) {
|
TEST(AddressSanitizer, ThreadedMallocStressTest) {
|
||||||
const int kNumThreads = 4;
|
const int kNumThreads = 4;
|
||||||
|
const int kNumIterations = (ASAN_LOW_MEMORY) ? 10000 : 100000;
|
||||||
pthread_t t[kNumThreads];
|
pthread_t t[kNumThreads];
|
||||||
for (int i = 0; i < kNumThreads; i++) {
|
for (int i = 0; i < kNumThreads; i++) {
|
||||||
#if ASAN_LOW_MEMORY == 1
|
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress,
|
||||||
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)10000);
|
(void*)kNumIterations);
|
||||||
#else
|
|
||||||
pthread_create(&t[i], 0, (void* (*)(void *x))MallocStress, (void*)100000);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < kNumThreads; i++) {
|
for (int i = 0; i < kNumThreads; i++) {
|
||||||
pthread_join(t[i], 0);
|
pthread_join(t[i], 0);
|
||||||
|
|
Loading…
Reference in New Issue