Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator.h @@ -72,8 +72,10 @@ template INLINE void RandomShuffle(T *a, u32 n, u32 *rand_state) { if (n <= 1) return; + u32 state = *rand_state; for (u32 i = n - 1; i > 0; i--) - Swap(a[i], a[RandN(rand_state, i + 1)]); + Swap(a[i], a[RandN(&state, i + 1)]); + *rand_state = state; } #include "sanitizer_allocator_size_class_map.h" Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h =================================================================== --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -64,8 +64,8 @@ struct TransferBatch { static const uptr kMaxNumCached = SizeClassMap::kMaxNumCachedHint - 2; void SetFromArray(void *batch[], uptr count) { + DCHECK_LE(count, kMaxNumCached); count_ = count; - CHECK_LE(count_, kMaxNumCached); for (uptr i = 0; i < count; i++) batch_[i] = batch[i]; } @@ -73,9 +73,9 @@ void Clear() { count_ = 0; } void Add(void *ptr) { batch_[count_++] = ptr; - CHECK_LE(count_, kMaxNumCached); + DCHECK_LE(count_, kMaxNumCached); } - void CopyToArray(void *to_batch[]) { + void CopyToArray(void *to_batch[]) const { for (uptr i = 0, n = Count(); i < n; i++) to_batch[i] = batch_[i]; } @@ -153,7 +153,7 @@ NOINLINE TransferBatch *AllocateBatch(AllocatorStats *stat, AllocatorCache *c, uptr class_id) { - CHECK_LT(class_id, kNumClasses); + DCHECK_LT(class_id, kNumClasses); SizeClassInfo *sci = GetSizeClassInfo(class_id); SpinMutexLock l(&sci->mutex); if (sci->free_list.empty()) { @@ -168,15 +168,13 @@ NOINLINE void DeallocateBatch(AllocatorStats *stat, uptr class_id, TransferBatch *b) { - CHECK_LT(class_id, kNumClasses); + DCHECK_LT(class_id, kNumClasses); CHECK_GT(b->Count(), 0); SizeClassInfo *sci = GetSizeClassInfo(class_id); SpinMutexLock l(&sci->mutex); sci->free_list.push_front(b); } - uptr GetRegionBeginBySizeClass(uptr class_id) { return 0; } - bool PointerIsMine(const void *p) { uptr mem = reinterpret_cast(p); if (mem < kSpaceBeg || mem >= kSpaceBeg + kSpaceSize) @@ -252,12 +250,9 @@ } } - void PrintStats() { - } + void PrintStats() {} - static uptr AdditionalSize() { - return 0; - } + static uptr AdditionalSize() { return 0; } typedef SizeClassMap SizeClassMapT; static const uptr kNumClasses = SizeClassMap::kNumClasses; @@ -267,7 +262,7 @@ static const uptr kNumPossibleRegions = kSpaceSize / kRegionSize; struct ALIGNED(SANITIZER_CACHE_LINE_SIZE) SizeClassInfo { - SpinMutex mutex; + StaticSpinMutex mutex; IntrusiveList free_list; u32 rand_state; }; @@ -284,8 +279,8 @@ } uptr AllocateRegion(AllocatorStats *stat, uptr class_id) { - CHECK_LT(class_id, kNumClasses); - uptr res = reinterpret_cast(MmapAlignedOrDieOnFatalError( + DCHECK_LT(class_id, kNumClasses); + const uptr res = reinterpret_cast(MmapAlignedOrDieOnFatalError( kRegionSize, kRegionSize, PrimaryAllocatorName)); if (UNLIKELY(!res)) return 0;