The memcpy implementation is not completely stupid but is almost certainly not as good as a carefully tuned and optimised one. Building snmalloc with FreeBSD's libc memcpy + jemalloc and with this, each 10 times, does not show a statistically significant performance difference at 95% confidence. The snmalloc version has very slightly lower median and worst-case times. This is in no way a sensible benchmark, but it serves as a smoke test for significant performance regressions. The CI self-host job now uses the checked memcpy. This also fixes an off-by-one error in the external bounds. This is triggered by ninja, so we will see breakage in CI if it is reintroduced. In debug builds, we provide a verbose error containing the address of the allocation, the base and bounds of the allocation, and a backtrace. The backtrace was broken by the CI cleanup moving the BACKTRACE_HEADER macro into the SNMALLOC_ namespace. This is also fixed. The test involves hijacking `abort`, which doesn't work everywhere. It also requires `backtrace` to work in configurations where stack traces are enabled. This is disabled in QEMU because `backtrace` appears to crash reliably in QEMU user mode. For now, in the -checks build configurations, we are hitting a slow path in the pagemap on accesses so that the pages that are `PROT_NONE` don't cause crashes. These need to be made read-only, but this requires a PAL change.
29 lines
820 B
C++
29 lines
820 B
C++
#pragma once
|
|
|
|
// Core implementation of snmalloc independent of the configuration mode
|
|
#include "../snmalloc_core.h"
|
|
|
|
#ifndef SNMALLOC_PROVIDE_OWN_CONFIG
|
|
# include "../backend/globalconfig.h"
|
|
// The default configuration for snmalloc is used if alternative not defined
|
|
namespace snmalloc
|
|
{
|
|
using Alloc = snmalloc::LocalAllocator<snmalloc::Globals>;
|
|
} // namespace snmalloc
|
|
#endif
|
|
|
|
// User facing API surface, needs to know what `Alloc` is.
|
|
#include "../snmalloc_front.h"
|
|
|
|
#ifndef SNMALLOC_EXPORT
|
|
# define SNMALLOC_EXPORT
|
|
#endif
|
|
#ifdef SNMALLOC_STATIC_LIBRARY_PREFIX
|
|
# define __SN_CONCAT(a, b) a##b
|
|
# define __SN_EVALUATE(a, b) __SN_CONCAT(a, b)
|
|
# define SNMALLOC_NAME_MANGLE(a) \
|
|
__SN_EVALUATE(SNMALLOC_STATIC_LIBRARY_PREFIX, a)
|
|
#elif !defined(SNMALLOC_NAME_MANGLE)
|
|
# define SNMALLOC_NAME_MANGLE(a) a
|
|
#endif
|