Skip to content

Commit

Permalink
NFC: rename ConceptBound to IsBound
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf-msr committed Jul 7, 2022
1 parent df1dbc9 commit b2c75df
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 73 deletions.
2 changes: 1 addition & 1 deletion docs/StrictProvenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions src/snmalloc/aal/aal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/snmalloc/aal/aal_cheri.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/snmalloc/aal/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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());
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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());
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/backend/fixedglobalconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>>
Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/backend_helpers/empty_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions src/snmalloc/backend_helpers/range_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/snmalloc/backend_helpers/smallbuddyrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions src/snmalloc/ds_core/ptrwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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> &&
Expand Down Expand Up @@ -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>;
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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>>
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/snmalloc/mem/backend_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down
Loading

0 comments on commit b2c75df

Please sign in to comment.