diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f62c1..cd578c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,10 +48,6 @@ if(USE_SNMALLOC_STATS) add_definitions(-DUSE_SNMALLOC_STATS) endif() -if(CACHE_FRIENDLY_OFFSET) - add_definitions(-DCACHE_FRIENDLY_OFFSET=${CACHE_FRIENDLY_OFFSET}) -endif() - if(USE_MEASURE) add_definitions(-DUSE_MEASURE) endif() @@ -66,6 +62,10 @@ macro(add_shim name) target_include_directories(${name} PRIVATE src) target_compile_definitions(${name} PRIVATE "SNMALLOC_EXPORT=__attribute__((visibility(\"default\")))") set_target_properties(${name} PROPERTIES CXX_VISIBILITY_PRESET hidden) + + if(CACHE_FRIENDLY_OFFSET) + target_compile_definitions(${name} PRIVATE -DCACHE_FRIENDLY_OFFSET=${CACHE_FRIENDLY_OFFSET}) + endif() endmacro() if(NOT MSVC) diff --git a/src/mem/metaslab.h b/src/mem/metaslab.h index 88b6712..ba99f81 100644 --- a/src/mem/metaslab.h +++ b/src/mem/metaslab.h @@ -150,7 +150,8 @@ namespace snmalloc } // Check we terminated traversal on a correctly aligned block - assert(((curr & ~1) - offset) % size == 0); + uint16_t start = remove_cache_friendly_offset(curr & ~1, sizeclass); + assert((start - offset) % size == 0); if (curr != link) { diff --git a/src/mem/sizeclass.h b/src/mem/sizeclass.h index c9175c6..95f4be6 100644 --- a/src/mem/sizeclass.h +++ b/src/mem/sizeclass.h @@ -7,8 +7,7 @@ namespace snmalloc constexpr static uint16_t get_slab_offset(uint8_t sc, bool is_short); constexpr static size_t sizeclass_to_size(uint8_t sizeclass); constexpr static size_t sizeclass_to_cache_friendly_mask(uint8_t sizeclass); - constexpr static size_t - sizeclass_to_inverse_cache_friendly_mask(uint8_t sizeclass); + constexpr static size_t sizeclass_to_inverse_cache_friendly_mask(uint8_t sc); constexpr static uint16_t medium_slab_free(uint8_t sizeclass); static inline uint8_t size_to_sizeclass(size_t size)