17 #ifndef PMALLOC_UTIL_HPP 18 #define PMALLOC_UTIL_HPP 28 { TL_CurrArena_[rid] = val; }
31 {
return TL_CurrArena_[rid]; }
40 { CacheLineSize_ = sz; }
43 { CacheLineMask_ = mask; }
46 { assert(CacheLineSize_ != UINT32_MAX);
return CacheLineSize_; }
49 { assert(CacheLineMask_ != UINTPTR_MAX);
return CacheLineMask_; }
52 {
return static_cast<void*
>(
56 {
return static_cast<void*
>(
60 {
return 2*
sizeof(size_t); }
66 {
return 2*
sizeof(size_t); }
76 {
return *(
static_cast<size_t*
>(mem)); }
80 return *(
static_cast<size_t*
>(mem)); }
83 {
return reinterpret_cast<size_t*
>(
84 static_cast<char*
>(mem) +
sizeof(
size_t)); }
88 return reinterpret_cast<size_t*
>(
89 static_cast<char*
>(mem) +
sizeof(
size_t)); }
99 assert(bin_number &&
"Non-zero bin number!");
100 assert(!(bin_number %
get_alignment()) &&
"Unaligned bin number!");
105 {
return (reinterpret_cast<uintptr_t>(p) &
107 reinterpret_cast<uintptr_t
>(p); }
110 {
return (reinterpret_cast<uintptr_t>(p1) &
112 (
reinterpret_cast<uintptr_t
>(p2) &
122 static uint32_t CacheLineSize_;
123 static uintptr_t CacheLineMask_;
static void * ptr2mem(void *ptr)
Definition: pmalloc_util.hpp:55
static void set_cache_line_mask(uintptr_t mask)
Definition: pmalloc_util.hpp:42
static size_t get_requested_alloc_size_from_mem(void *mem)
Definition: pmalloc_util.hpp:75
const uint32_t kMaxNumPRegions_
Definition: pregion_configs.hpp:29
static size_t get_alignment()
Definition: pmalloc_util.hpp:59
const uint32_t kNumArenas_
Definition: pregion_configs.hpp:30
const uint32_t kMaxFreeCategory_
Definition: pregion_configs.hpp:32
uint32_t region_id_t
Definition: pregion_configs.hpp:22
static void * mem2ptr(void *mem)
Definition: pmalloc_util.hpp:51
static bool is_ptr_allocated(void *ptr)
Definition: pmalloc_util.hpp:94
static size_t get_metadata_size()
Definition: pmalloc_util.hpp:65
static size_t * get_is_allocated_ptr_from_mem(void *mem)
Definition: pmalloc_util.hpp:82
static bool is_cache_line_aligned(void *p)
Definition: pmalloc_util.hpp:104
static uint32_t get_tl_next_arena(region_id_t rid)
Definition: pmalloc_util.hpp:33
static uint32_t get_tl_curr_arena(region_id_t rid)
Definition: pmalloc_util.hpp:30
static void set_cache_line_size(uint32_t sz)
Definition: pmalloc_util.hpp:39
static bool is_mem_allocated(void *mem)
Definition: pmalloc_util.hpp:91
static size_t get_smallest_actual_alloc_size()
Definition: pmalloc_util.hpp:68
static uintptr_t get_cache_line_mask()
Definition: pmalloc_util.hpp:48
static uint32_t get_bin_number(size_t sz)
Definition: pmalloc_util.hpp:115
static uint32_t get_cache_line_size()
Definition: pmalloc_util.hpp:45
Definition: pmalloc_util.hpp:22
static size_t * get_is_allocated_ptr_from_ptr(void *ptr)
Definition: pmalloc_util.hpp:86
static bool is_valid_tl_curr_arena(region_id_t rid)
Definition: pmalloc_util.hpp:36
static void set_tl_curr_arena(region_id_t rid, uint32_t val)
Definition: pmalloc_util.hpp:27
static size_t get_alignment_mask()
Definition: pmalloc_util.hpp:62
static size_t get_requested_alloc_size_from_ptr(void *ptr)
Definition: pmalloc_util.hpp:78
static size_t get_actual_alloc_size(size_t sz)
Definition: pmalloc_util.hpp:71
static uint32_t get_next_bin_number(uint32_t bin_number)
Definition: pmalloc_util.hpp:97
static void set_default_tl_curr_arena(region_id_t rid)
Definition: pmalloc_util.hpp:24
static bool is_on_different_cache_line(void *p1, void *p2)
Definition: pmalloc_util.hpp:109
Definition: atlas_alloc_cpp.hpp:21