forked from OSchip/llvm-project
[NFC][sanitizer] Remove sanitizer_persistent_allocator.cpp
We need to make it a template
This commit is contained in:
parent
03bfddae50
commit
05d46f627c
|
@ -1591,7 +1591,6 @@ compiler-rt/lib/sanitizer_common/sanitizer_errno.h
|
|||
compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_local_address_space_view.h
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_openbsd.cpp
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
|
||||
compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_openbsd.cpp
|
||||
|
|
|
@ -18,7 +18,6 @@ set(SANITIZER_SOURCES_NOTERMINATION
|
|||
sanitizer_mac.cpp
|
||||
sanitizer_mutex.cpp
|
||||
sanitizer_netbsd.cpp
|
||||
sanitizer_persistent_allocator.cpp
|
||||
sanitizer_platform_limits_freebsd.cpp
|
||||
sanitizer_platform_limits_linux.cpp
|
||||
sanitizer_platform_limits_netbsd.cpp
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define SANITIZER_CHAINED_ORIGIN_DEPOT_H
|
||||
|
||||
#include "sanitizer_common.h"
|
||||
#include "sanitizer_persistent_allocator.h"
|
||||
#include "sanitizer_stackdepotbase.h"
|
||||
|
||||
namespace __sanitizer {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
//===-- sanitizer_persistent_allocator.cpp ----------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file is shared between AddressSanitizer and ThreadSanitizer
|
||||
// run-time libraries.
|
||||
//===----------------------------------------------------------------------===//
|
||||
#include "sanitizer_persistent_allocator.h"
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
void *PersistentAllocator::refillAndAlloc(uptr size) {
|
||||
// If failed, lock, retry and alloc new superblock.
|
||||
SpinMutexLock l(&mtx);
|
||||
for (;;) {
|
||||
void *s = tryAlloc(size);
|
||||
if (s)
|
||||
return s;
|
||||
atomic_store(®ion_pos, 0, memory_order_relaxed);
|
||||
uptr allocsz = 64 * 1024;
|
||||
if (allocsz < size)
|
||||
allocsz = size;
|
||||
uptr mem = (uptr)MmapOrDie(allocsz, "stack depot");
|
||||
atomic_fetch_add(&mapped_size, allocsz, memory_order_relaxed);
|
||||
atomic_store(®ion_end, mem + allocsz, memory_order_release);
|
||||
atomic_store(®ion_pos, mem, memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
|
@ -58,6 +58,24 @@ inline void *PersistentAllocator::alloc(uptr size) {
|
|||
return refillAndAlloc(size);
|
||||
}
|
||||
|
||||
inline void *PersistentAllocator::refillAndAlloc(uptr size) {
|
||||
// If failed, lock, retry and alloc new superblock.
|
||||
SpinMutexLock l(&mtx);
|
||||
for (;;) {
|
||||
void *s = tryAlloc(size);
|
||||
if (s)
|
||||
return s;
|
||||
atomic_store(®ion_pos, 0, memory_order_relaxed);
|
||||
uptr allocsz = 64 * 1024;
|
||||
if (allocsz < size)
|
||||
allocsz = size;
|
||||
uptr mem = (uptr)MmapOrDie(allocsz, "stack depot");
|
||||
atomic_fetch_add(&mapped_size, allocsz, memory_order_relaxed);
|
||||
atomic_store(®ion_end, mem + allocsz, memory_order_release);
|
||||
atomic_store(®ion_pos, mem, memory_order_release);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // SANITIZER_PERSISTENT_ALLOCATOR_H
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "sanitizer_atomic.h"
|
||||
#include "sanitizer_internal_defs.h"
|
||||
#include "sanitizer_mutex.h"
|
||||
#include "sanitizer_persistent_allocator.h"
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ type ^
|
|||
..\..\sanitizer_common\sanitizer_win.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_deadlock_detector1.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_stackdepot.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_persistent_allocator.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_flag_parser.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_symbolizer.cpp ^
|
||||
..\..\sanitizer_common\sanitizer_termination.cpp ^
|
||||
|
|
|
@ -27,7 +27,6 @@ SRCS="
|
|||
../../sanitizer_common/sanitizer_flags.cpp
|
||||
../../sanitizer_common/sanitizer_libc.cpp
|
||||
../../sanitizer_common/sanitizer_mutex.cpp
|
||||
../../sanitizer_common/sanitizer_persistent_allocator.cpp
|
||||
../../sanitizer_common/sanitizer_printf.cpp
|
||||
../../sanitizer_common/sanitizer_suppressions.cpp
|
||||
../../sanitizer_common/sanitizer_thread_registry.cpp
|
||||
|
|
|
@ -84,7 +84,6 @@ source_set("sources") {
|
|||
"sanitizer_mutex.cpp",
|
||||
"sanitizer_mutex.h",
|
||||
"sanitizer_netbsd.cpp",
|
||||
"sanitizer_persistent_allocator.cpp",
|
||||
"sanitizer_persistent_allocator.h",
|
||||
"sanitizer_placement_new.h",
|
||||
"sanitizer_platform.h",
|
||||
|
|
Loading…
Reference in New Issue