NFC: rename ConceptBound to IsBound

This commit is contained in:
Nathaniel Wesley Filardo
2022-07-01 12:30:31 +01:00
committed by Nathaniel Filardo
parent df1dbc997f
commit b2c75dffb7
14 changed files with 69 additions and 73 deletions

View File

@@ -175,7 +175,7 @@ We introduce a multi-dimensional space of bounds. The facets are `enum class`-e
* `Wildness` captures whether the pointer has been checked to belong to this allocator.
These `dimension`s are composited using a `capptr::bound<>` type that we use as `B` in `CapPtr<T, B>`.
This is enforced (loosely) using the `ConceptBound` C++20 concept.
This is enforced (loosely) using the `IsBound` C++20 concept.
The namespace `snmalloc::capptr::bounds` contains particular points in the space of `capptr::bound<>` types:

View File

@@ -198,8 +198,8 @@ namespace snmalloc
*/
template<
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) BOut,
SNMALLOC_CONCEPT(capptr::ConceptBound) BIn,
SNMALLOC_CONCEPT(capptr::IsBound) BOut,
SNMALLOC_CONCEPT(capptr::IsBound) BIn,
typename U = T>
static SNMALLOC_FAST_PATH CapPtr<T, BOut>
capptr_bound(CapPtr<U, BIn> a, size_t size) noexcept

View File

@@ -63,8 +63,8 @@ namespace snmalloc
template<
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) BOut,
SNMALLOC_CONCEPT(capptr::ConceptBound) BIn,
SNMALLOC_CONCEPT(capptr::IsBound) BOut,
SNMALLOC_CONCEPT(capptr::IsBound) BIn,
typename U = T>
static SNMALLOC_FAST_PATH CapPtr<T, BOut>
capptr_bound(CapPtr<U, BIn> a, size_t size) noexcept

View File

@@ -30,7 +30,7 @@ namespace snmalloc
unsafe_to_uintptr<T>(base) + static_cast<uintptr_t>(diff));
}
template<SNMALLOC_CONCEPT(capptr::ConceptBound) bounds, typename T>
template<SNMALLOC_CONCEPT(capptr::IsBound) bounds, typename T>
inline CapPtr<void, bounds>
pointer_offset(CapPtr<T, bounds> base, size_t diff)
{
@@ -48,7 +48,7 @@ namespace snmalloc
return reinterpret_cast<U*>(reinterpret_cast<char*>(base) + diff);
}
template<SNMALLOC_CONCEPT(capptr::ConceptBound) bounds, typename T>
template<SNMALLOC_CONCEPT(capptr::IsBound) bounds, typename T>
inline CapPtr<void, bounds>
pointer_offset_signed(CapPtr<T, bounds> base, ptrdiff_t diff)
{
@@ -72,7 +72,7 @@ namespace snmalloc
* as per above, and uses the wrapper types in its own definition, e.g., of
* capptr_bound.
*/
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) bounds>
inline SNMALLOC_FAST_PATH address_t address_cast(CapPtr<T, bounds> a)
{
return address_cast(a.unsafe_ptr());
@@ -136,7 +136,7 @@ namespace snmalloc
template<
size_t alignment,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
SNMALLOC_CONCEPT(capptr::IsBound) bounds>
inline CapPtr<T, bounds> pointer_align_down(CapPtr<void, bounds> p)
{
return CapPtr<T, bounds>::unsafe_from(
@@ -174,7 +174,7 @@ namespace snmalloc
template<
size_t alignment,
typename T = void,
SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
SNMALLOC_CONCEPT(capptr::IsBound) bounds>
inline CapPtr<T, bounds> pointer_align_up(CapPtr<void, bounds> p)
{
return CapPtr<T, bounds>::unsafe_from(
@@ -204,7 +204,7 @@ namespace snmalloc
#endif
}
template<typename T = void, SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<typename T = void, SNMALLOC_CONCEPT(capptr::IsBound) bounds>
inline CapPtr<T, bounds>
pointer_align_down(CapPtr<void, bounds> p, size_t alignment)
{
@@ -229,7 +229,7 @@ namespace snmalloc
#endif
}
template<typename T = void, SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<typename T = void, SNMALLOC_CONCEPT(capptr::IsBound) bounds>
inline CapPtr<T, bounds>
pointer_align_up(CapPtr<void, bounds> p, size_t alignment)
{
@@ -252,8 +252,8 @@ namespace snmalloc
template<
typename T = void,
typename U = void,
SNMALLOC_CONCEPT(capptr::ConceptBound) Tbounds,
SNMALLOC_CONCEPT(capptr::ConceptBound) Ubounds>
SNMALLOC_CONCEPT(capptr::IsBound) Tbounds,
SNMALLOC_CONCEPT(capptr::IsBound) Ubounds>
inline size_t pointer_diff(CapPtr<T, Tbounds> base, CapPtr<U, Ubounds> cursor)
{
return pointer_diff(base.unsafe_ptr(), cursor.unsafe_ptr());
@@ -272,8 +272,8 @@ namespace snmalloc
template<
typename T = void,
typename U = void,
SNMALLOC_CONCEPT(capptr::ConceptBound) Tbounds,
SNMALLOC_CONCEPT(capptr::ConceptBound) Ubounds>
SNMALLOC_CONCEPT(capptr::IsBound) Tbounds,
SNMALLOC_CONCEPT(capptr::IsBound) Ubounds>
inline ptrdiff_t
pointer_diff_signed(CapPtr<T, Tbounds> base, CapPtr<U, Ubounds> cursor)
{

View File

@@ -87,7 +87,7 @@ namespace snmalloc
}
/* Verify that a pointer points into the region managed by this config */
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) B>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) B>
static SNMALLOC_FAST_PATH CapPtr<
T,
typename B::template with_wildness<capptr::dimension::Wildness::Tame>>

View File

@@ -3,7 +3,7 @@
namespace snmalloc
{
template<SNMALLOC_CONCEPT(capptr::ConceptBound) B = capptr::bounds::Arena>
template<SNMALLOC_CONCEPT(capptr::IsBound) B = capptr::bounds::Arena>
class EmptyRange
{
public:

View File

@@ -4,10 +4,7 @@
namespace snmalloc
{
template<
size_t MIN_BITS,
SNMALLOC_CONCEPT(capptr::ConceptBound) B,
typename F>
template<size_t MIN_BITS, SNMALLOC_CONCEPT(capptr::IsBound) B, typename F>
void range_to_pow_2_blocks(CapPtr<void, B> base, size_t length, F f)
{
auto end = pointer_offset(base, length);

View File

@@ -10,7 +10,7 @@ namespace snmalloc
* struct for representing the redblack nodes
* directly inside the meta data.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<SNMALLOC_CONCEPT(capptr::IsBound) bounds>
struct FreeChunk
{
CapPtr<FreeChunk, bounds> left;
@@ -20,7 +20,7 @@ namespace snmalloc
/**
* Class for using the allocations own space to store in the RBTree.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<SNMALLOC_CONCEPT(capptr::IsBound) bounds>
class BuddyInplaceRep
{
public:

View File

@@ -175,7 +175,7 @@ namespace snmalloc
* with that spelling. Both seem happy with this formulation.
*/
template<typename T>
concept ConceptBound =
concept IsBound =
ConceptSame<decltype(T::spatial), const dimension::Spatial> &&
ConceptSame<decltype(T::address_space_control),
const dimension::AddressSpaceControl> &&
@@ -236,7 +236,7 @@ namespace snmalloc
* annotation. This is used by the PAL's capptr_to_user_address_control
* function to compute its return value's annotation.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) B>
template<SNMALLOC_CONCEPT(capptr::IsBound) B>
using user_address_control_type =
typename B::template with_address_space_control<
dimension::AddressSpaceControl::User>;
@@ -246,8 +246,8 @@ namespace snmalloc
* Chunk and ChunkD are considered eqivalent here.
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BI,
SNMALLOC_CONCEPT(capptr::ConceptBound) BO>
SNMALLOC_CONCEPT(capptr::IsBound) BI,
SNMALLOC_CONCEPT(capptr::IsBound) BO>
SNMALLOC_CONSTEVAL bool is_spatial_refinement()
{
if (BI::address_space_control != BO::address_space_control)
@@ -268,7 +268,7 @@ namespace snmalloc
* A pointer annotated with a "phantom type parameter" carrying a static
* summary of its StrictProvenance metadata.
*/
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) bounds>
class CapPtr
{
T* unsafe_capptr;
@@ -446,7 +446,7 @@ namespace snmalloc
/**
* It's safe to mark any CapPtr as Wild.
*/
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) B>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) B>
static inline SNMALLOC_FAST_PATH CapPtr<
T,
typename B::template with_wildness<capptr::dimension::Wildness::Wild>>
@@ -467,7 +467,7 @@ namespace snmalloc
* annotations around an un-annotated std::atomic<T*>, to appease C++, yet
* will expose or consume only CapPtr<T> with the same bounds annotation.
*/
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) bounds>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) bounds>
class AtomicCapPtr
{
std::atomic<T*> unsafe_capptr;

View File

@@ -42,7 +42,7 @@ namespace snmalloc
template<
SNMALLOC_CONCEPT(IsConfigDomestication) Config,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
constexpr SNMALLOC_FAST_PATH_INLINE auto has_domesticate(int)
-> std::enable_if_t<
std::is_same_v<
@@ -65,7 +65,7 @@ namespace snmalloc
template<
SNMALLOC_CONCEPT(IsConfig) Config,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
constexpr SNMALLOC_FAST_PATH_INLINE bool has_domesticate(long)
{
return false;
@@ -80,7 +80,7 @@ namespace snmalloc
template<
SNMALLOC_CONCEPT(IsConfig) Config,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
SNMALLOC_FAST_PATH_INLINE auto
capptr_domesticate(typename Config::LocalState* ls, CapPtr<T, B> p)
{

View File

@@ -57,8 +57,7 @@ namespace snmalloc
{
public:
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue =
capptr::bounds::AllocWild>
SNMALLOC_CONCEPT(capptr::IsBound) BQueue = capptr::bounds::AllocWild>
class T;
/**
@@ -67,13 +66,13 @@ namespace snmalloc
* place. Give it a shorter name (Object::BQueuePtr<BQueue>) for
* convenience.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
using BQueuePtr = CapPtr<Object::T<BQueue>, BQueue>;
/**
* As with BQueuePtr, but atomic.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
using BAtomicQueuePtr = AtomicCapPtr<Object::T<BQueue>, BQueue>;
/**
@@ -83,16 +82,16 @@ namespace snmalloc
* looks a little nicer than "CapPtr<freelist::Object::T<BQueue>, BView>".
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
using BHeadPtr = CapPtr<Object::T<BQueue>, BView>;
/**
* As with BHeadPtr, but atomic.
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
using BAtomicHeadPtr = AtomicCapPtr<Object::T<BQueue>, BView>;
/**
@@ -112,14 +111,14 @@ namespace snmalloc
* require size to be threaded through, but would provide more OOB
* detection.
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
class T
{
template<
bool,
bool,
SNMALLOC_CONCEPT(capptr::ConceptBound),
SNMALLOC_CONCEPT(capptr::ConceptBound)>
SNMALLOC_CONCEPT(capptr::IsBound),
SNMALLOC_CONCEPT(capptr::IsBound)>
friend class Builder;
friend class Object;
@@ -139,7 +138,7 @@ namespace snmalloc
public:
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView = typename BQueue::
SNMALLOC_CONCEPT(capptr::IsBound) BView = typename BQueue::
template with_wildness<capptr::dimension::Wildness::Tame>,
typename Domesticator>
BHeadPtr<BView, BQueue>
@@ -164,7 +163,7 @@ namespace snmalloc
* Read the next pointer
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView = typename BQueue::
SNMALLOC_CONCEPT(capptr::IsBound) BView = typename BQueue::
template with_wildness<capptr::dimension::Wildness::Tame>,
typename Domesticator>
BHeadPtr<BView, BQueue>
@@ -203,8 +202,8 @@ namespace snmalloc
// Note the inverted template argument order, since BView is inferable.
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue,
SNMALLOC_CONCEPT(capptr::ConceptBound) BView>
SNMALLOC_CONCEPT(capptr::IsBound) BQueue,
SNMALLOC_CONCEPT(capptr::IsBound) BView>
static BHeadPtr<BView, BQueue> make(CapPtr<void, BView> p)
{
return p.template as_static<Object::T<BQueue>>();
@@ -213,7 +212,7 @@ namespace snmalloc
/**
* A container-of operation to convert &f->next_object to f
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static Object::T<BQueue>*
from_next_ptr(CapPtr<Object::T<BQueue>, BQueue>* ptr)
{
@@ -225,7 +224,7 @@ namespace snmalloc
/**
* Involutive encryption with raw pointers
*/
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
inline static Object::T<BQueue>*
code_next(address_t curr, Object::T<BQueue>* next, const FreeListKey& key)
{
@@ -265,8 +264,8 @@ namespace snmalloc
* is likely (but not necessarily) Wild.
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
inline static BQueuePtr<BQueue> encode_next(
address_t curr, BHeadPtr<BView, BQueue> next, const FreeListKey& key)
{
@@ -290,8 +289,8 @@ namespace snmalloc
* encapsulated within Object and we do not capture any of it statically.
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
inline static BHeadPtr<BView, BQueue> decode_next(
address_t curr, BHeadPtr<BView, BQueue> next, const FreeListKey& key)
{
@@ -300,8 +299,8 @@ namespace snmalloc
}
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static void assert_view_queue_bounds()
{
static_assert(
@@ -326,8 +325,8 @@ namespace snmalloc
* next->next_object is nullptr).
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static BQueuePtr<BQueue>* store_next(
BQueuePtr<BQueue>* curr,
BHeadPtr<BView, BQueue> next,
@@ -345,7 +344,7 @@ namespace snmalloc
return &(next->next_object);
}
template<SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
template<SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static void store_null(BQueuePtr<BQueue>* curr, const FreeListKey& key)
{
*curr =
@@ -358,8 +357,8 @@ namespace snmalloc
* Uses the atomic view of next, so can be used in the message queues.
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static void atomic_store_next(
BHeadPtr<BView, BQueue> curr,
BHeadPtr<BView, BQueue> next,
@@ -381,8 +380,8 @@ namespace snmalloc
}
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue>
SNMALLOC_CONCEPT(capptr::IsBound) BView,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue>
static void
atomic_store_null(BHeadPtr<BView, BQueue> curr, const FreeListKey& key)
{
@@ -428,8 +427,8 @@ namespace snmalloc
* Checks signing of pointers
*/
template<
SNMALLOC_CONCEPT(capptr::ConceptBound) BView = capptr::bounds::Alloc,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue = capptr::bounds::AllocWild>
SNMALLOC_CONCEPT(capptr::IsBound) BView = capptr::bounds::Alloc,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue = capptr::bounds::AllocWild>
class Iter
{
Object::BHeadPtr<BView, BQueue> curr{nullptr};
@@ -508,8 +507,8 @@ namespace snmalloc
template<
bool RANDOM,
bool INIT = true,
SNMALLOC_CONCEPT(capptr::ConceptBound) BView = capptr::bounds::Alloc,
SNMALLOC_CONCEPT(capptr::ConceptBound) BQueue = capptr::bounds::AllocWild>
SNMALLOC_CONCEPT(capptr::IsBound) BView = capptr::bounds::Alloc,
SNMALLOC_CONCEPT(capptr::IsBound) BQueue = capptr::bounds::AllocWild>
class Builder
{
static constexpr size_t LENGTH = RANDOM ? 2 : 1;

View File

@@ -84,7 +84,7 @@ namespace snmalloc
typename PAL = DefaultPal,
typename AAL = Aal,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
static inline typename std::enable_if_t<
!aal_supports<StrictProvenance, AAL>,
CapPtr<T, capptr::user_address_control_type<B>>>
@@ -98,7 +98,7 @@ namespace snmalloc
typename PAL = DefaultPal,
typename AAL = Aal,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
static SNMALLOC_FAST_PATH typename std::enable_if_t<
aal_supports<StrictProvenance, AAL>,
CapPtr<T, capptr::user_address_control_type<B>>>
@@ -119,7 +119,7 @@ namespace snmalloc
typename PAL,
bool page_aligned = false,
typename T,
SNMALLOC_CONCEPT(capptr::ConceptBound) B>
SNMALLOC_CONCEPT(capptr::IsBound) B>
static SNMALLOC_FAST_PATH void pal_zero(CapPtr<T, B> p, size_t sz)
{
static_assert(

View File

@@ -124,7 +124,7 @@ namespace snmalloc
* manage the address space it references by clearing the SW_VMEM
* permission bit.
*/
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) B>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) B>
static SNMALLOC_FAST_PATH CapPtr<T, capptr::user_address_control_type<B>>
capptr_to_user_address_control(CapPtr<T, B> p)
{

View File

@@ -79,7 +79,7 @@ namespace snmalloc
static inline uintptr_t domesticate_patch_value;
/* Verify that a pointer points into the region managed by this config */
template<typename T, SNMALLOC_CONCEPT(capptr::ConceptBound) B>
template<typename T, SNMALLOC_CONCEPT(capptr::IsBound) B>
static CapPtr<
T,
typename B::template with_wildness<capptr::dimension::Wildness::Tame>>