Clang format.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace snmalloc
|
|||||||
class MemoryProviderStateMixin : public PAL
|
class MemoryProviderStateMixin : public PAL
|
||||||
{
|
{
|
||||||
std::atomic_flag lock = ATOMIC_FLAG_INIT;
|
std::atomic_flag lock = ATOMIC_FLAG_INIT;
|
||||||
void* bump = 0;
|
void* bump = nullptr;
|
||||||
size_t remaining = 0;
|
size_t remaining = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -67,31 +67,29 @@ namespace snmalloc
|
|||||||
*/
|
*/
|
||||||
ModArray<NUM_LARGE_CLASSES, MPMCStack<Largeslab, RequiresInit>> large_stack;
|
ModArray<NUM_LARGE_CLASSES, MPMCStack<Largeslab, RequiresInit>> large_stack;
|
||||||
|
|
||||||
static MemoryProviderStateMixin<PAL>* make() noexcept
|
static MemoryProviderStateMixin<PAL>* make() noexcept
|
||||||
{
|
{
|
||||||
// Temporary storage to start the allocator in.
|
// Temporary storage to start the allocator in.
|
||||||
MemoryProviderStateMixin<PAL> local;
|
MemoryProviderStateMixin<PAL> local;
|
||||||
|
|
||||||
// Allocate permanent storage for the allocator usung temporary allocator
|
// Allocate permanent storage for the allocator usung temporary allocator
|
||||||
MemoryProviderStateMixin<PAL>* allocated
|
MemoryProviderStateMixin<PAL>* allocated =
|
||||||
= local.alloc_chunk<MemoryProviderStateMixin<PAL>, 1>();
|
local.alloc_chunk<MemoryProviderStateMixin<PAL>, 1>();
|
||||||
|
|
||||||
// Put temporary allocator we have used, into the permanent storage.
|
// Put temporary allocator we have used, into the permanent storage.
|
||||||
// memcpy is safe as this is entirely single threaded.
|
// memcpy is safe as this is entirely single threaded.
|
||||||
memcpy(allocated, &local, sizeof(MemoryProviderStateMixin<PAL>));
|
memcpy(allocated, &local, sizeof(MemoryProviderStateMixin<PAL>));
|
||||||
|
|
||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The last time we saw a low memory notification.
|
* The last time we saw a low memory notification.
|
||||||
*/
|
*/
|
||||||
std::atomic<uint64_t> last_low_memory_epoch = 0;
|
std::atomic<uint64_t> last_low_memory_epoch = 0;
|
||||||
std::atomic_flag lazy_decommit_guard = {};
|
std::atomic_flag lazy_decommit_guard = {};
|
||||||
|
|
||||||
|
|
||||||
void new_block()
|
void new_block()
|
||||||
{
|
{
|
||||||
// Reserve the smallest large_class which is SUPERSLAB_SIZE
|
// Reserve the smallest large_class which is SUPERSLAB_SIZE
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ namespace snmalloc
|
|||||||
**/
|
**/
|
||||||
static void register_cleanup()
|
static void register_cleanup()
|
||||||
{
|
{
|
||||||
#ifdef USE_SNMALLOC_STATS
|
# ifdef USE_SNMALLOC_STATS
|
||||||
Singleton<int, atexit_print_stats>::get();
|
Singleton<int, atexit_print_stats>::get();
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SNMALLOC_STATS
|
# ifdef USE_SNMALLOC_STATS
|
||||||
static void print_stats()
|
static void print_stats()
|
||||||
{
|
{
|
||||||
Stats s;
|
Stats s;
|
||||||
@@ -104,7 +104,7 @@ namespace snmalloc
|
|||||||
{
|
{
|
||||||
return atexit(print_stats);
|
return atexit(print_stats);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -143,15 +143,15 @@ namespace snmalloc
|
|||||||
*/
|
*/
|
||||||
static SNMALLOC_FAST_PATH Alloc* get()
|
static SNMALLOC_FAST_PATH Alloc* get()
|
||||||
{
|
{
|
||||||
#ifdef USE_MALLOC
|
# ifdef USE_MALLOC
|
||||||
return get_reference();
|
return get_reference();
|
||||||
#else
|
# else
|
||||||
auto alloc = get_reference();
|
auto alloc = get_reference();
|
||||||
auto new_alloc = lazy_replacement(alloc);
|
auto new_alloc = lazy_replacement(alloc);
|
||||||
return (likely(new_alloc == nullptr)) ?
|
return (likely(new_alloc == nullptr)) ?
|
||||||
alloc :
|
alloc :
|
||||||
reinterpret_cast<Alloc*>(new_alloc);
|
reinterpret_cast<Alloc*>(new_alloc);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ namespace snmalloc
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SNMALLOC_USE_THREAD_CLEANUP
|
# ifdef SNMALLOC_USE_THREAD_CLEANUP
|
||||||
/**
|
/**
|
||||||
* Entry point that allows libc to call into the allocator for per-thread
|
* Entry point that allows libc to call into the allocator for per-thread
|
||||||
* cleanup.
|
* cleanup.
|
||||||
@@ -210,9 +210,9 @@ namespace snmalloc
|
|||||||
ThreadAllocLibcCleanup::inner_release();
|
ThreadAllocLibcCleanup::inner_release();
|
||||||
}
|
}
|
||||||
using ThreadAlloc = ThreadAllocLibcCleanup;
|
using ThreadAlloc = ThreadAllocLibcCleanup;
|
||||||
#else
|
# else
|
||||||
using ThreadAlloc = ThreadAllocThreadDestructor;
|
using ThreadAlloc = ThreadAllocThreadDestructor;
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slow path for the placeholder replacement. The simple check that this is
|
* Slow path for the placeholder replacement. The simple check that this is
|
||||||
|
|||||||
Reference in New Issue
Block a user