Improve Debug test speed.
Removed some very expensive debug checks off the fast path of deallocation.
This commit is contained in:
@@ -61,7 +61,7 @@ namespace snmalloc
|
||||
* power of two.
|
||||
*/
|
||||
template<size_t alignment, typename T = void>
|
||||
inline T* pointer_align_down(void* p)
|
||||
SNMALLOC_FAST_PATH T* pointer_align_down(void* p)
|
||||
{
|
||||
static_assert(alignment > 0);
|
||||
static_assert(bits::next_pow2_const(alignment) == alignment);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace snmalloc
|
||||
|
||||
static constexpr size_t ADDRESS_BITS = is64() ? 48 : 32;
|
||||
|
||||
inline size_t clz(size_t x)
|
||||
SNMALLOC_FAST_PATH size_t clz(size_t x)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
# ifdef USE_LZCNT
|
||||
@@ -193,7 +193,7 @@ namespace snmalloc
|
||||
#endif
|
||||
}
|
||||
|
||||
inline size_t next_pow2(size_t x)
|
||||
SNMALLOC_FAST_PATH size_t next_pow2(size_t x)
|
||||
{
|
||||
// Correct for numbers [0..MAX_SIZE >> 1).
|
||||
// Returns 1 for x > (MAX_SIZE >> 1).
|
||||
@@ -223,7 +223,7 @@ namespace snmalloc
|
||||
return BITS - clz_const(x - 1);
|
||||
}
|
||||
|
||||
static inline size_t align_down(size_t value, size_t alignment)
|
||||
static SNMALLOC_FAST_PATH size_t align_down(size_t value, size_t alignment)
|
||||
{
|
||||
assert(next_pow2(alignment) == alignment);
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace snmalloc
|
||||
assert(rsize == sizeclass_to_size(meta.sizeclass));
|
||||
assert(sl.get_head() == (SlabLink*)pointer_offset(this, meta.link));
|
||||
assert(!meta.is_full());
|
||||
meta.debug_slab_invariant(this);
|
||||
|
||||
void* p = nullptr;
|
||||
bool p_has_value = false;
|
||||
@@ -156,7 +157,6 @@ namespace snmalloc
|
||||
if (meta.is_unused())
|
||||
error("Detected potential double free.");
|
||||
#endif
|
||||
meta.debug_slab_invariant(this);
|
||||
|
||||
if (unlikely(meta.return_object()))
|
||||
return false;
|
||||
@@ -170,7 +170,7 @@ namespace snmalloc
|
||||
|
||||
// Set the next pointer to the previous head.
|
||||
Metaslab::store_next(p, head);
|
||||
meta.debug_slab_invariant(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ namespace snmalloc
|
||||
dealloc_slow(SlabList* sl, Superslab* super, void* p)
|
||||
{
|
||||
Metaslab& meta = super->get_meta(this);
|
||||
meta.debug_slab_invariant(this);
|
||||
|
||||
if (meta.is_full())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user