зеркало из https://github.com/microsoft/snmalloc.git
Merge pull request #104 from CTSRD-CHERI/for-upstream-cheri-prep
Further CHERI prep
This commit is contained in:
Коммит
7f465f9a5d
|
@ -110,8 +110,9 @@ namespace snmalloc
|
|||
#endif
|
||||
|
||||
// Minimum allocation size is space for two pointers.
|
||||
static constexpr size_t MIN_ALLOC_BITS = bits::is64() ? 4 : 3;
|
||||
static constexpr size_t MIN_ALLOC_SIZE = 1 << MIN_ALLOC_BITS;
|
||||
static_assert(bits::next_pow2_const(sizeof(void*)) == sizeof(void*));
|
||||
static constexpr size_t MIN_ALLOC_SIZE = 2 * sizeof(void*);
|
||||
static constexpr size_t MIN_ALLOC_BITS = bits::ctz_const(MIN_ALLOC_SIZE);
|
||||
|
||||
// Slabs are 64 KiB unless constrained to 16 KiB.
|
||||
static constexpr size_t SLAB_BITS = ADDRESS_SPACE_CONSTRAINED ? 14 : 16;
|
||||
|
|
|
@ -142,12 +142,12 @@ namespace snmalloc
|
|||
|
||||
static Slab* get_slab(void* p)
|
||||
{
|
||||
return pointer_cast<Slab>(address_cast(p) & SLAB_MASK);
|
||||
return pointer_align_down<SLAB_SIZE, Slab>(p);
|
||||
}
|
||||
|
||||
static bool is_short(Slab* p)
|
||||
{
|
||||
return (address_cast(p) & SUPERSLAB_MASK) == address_cast(p);
|
||||
return pointer_align_down<SUPERSLAB_SIZE>(p) == p;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace snmalloc
|
|||
return std::pair(nullptr, 0);
|
||||
|
||||
shift -= BITS_PER_INDEX_LEVEL;
|
||||
ix = (addr >> shift) & ENTRIES_MASK;
|
||||
ix = (static_cast<size_t>(addr) >> shift) & ENTRIES_MASK;
|
||||
e = &value->entries[ix];
|
||||
|
||||
if constexpr (INDEX_LEVELS == 1)
|
||||
|
@ -211,7 +211,7 @@ namespace snmalloc
|
|||
return std::pair(nullptr, 0);
|
||||
|
||||
shift -= BITS_FOR_LEAF;
|
||||
ix = (addr >> shift) & LEAF_MASK;
|
||||
ix = (static_cast<size_t>(addr) >> shift) & LEAF_MASK;
|
||||
return std::pair(leaf, ix);
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ namespace snmalloc
|
|||
*/
|
||||
size_t index_for_address(uintptr_t p)
|
||||
{
|
||||
return reinterpret_cast<size_t>((p >> SHIFT) & (OS_PAGE_SIZE - 1));
|
||||
return bits::align_down(static_cast<size_t>(p) >> SHIFT, OS_PAGE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче