Files
snmalloc/src/aal/aal_concept.h
Nathaniel Wesley Filardo 9065893181 Overhaul CapPtr
* Switch to a multidimensional taxonomy.

  Rather than encoding the abstract bound states in a single enum, move to a
  more algebraic treatment.  The dimensions themselves are within the
  snmalloc::capptr_bounds namespace so that their fairly generic names do not
  conflict with consumer code.  Aliases for many points in the space are
  established outside that namespace for ease of use elsewhere.

* Introduce several new namespaces:

    * snmalloc::capptr::dimension holds each of the dimension enums

    * snmalloc::capptr holds the bound<> type itself and a ConceptBound

    * snmalloc::capptr::bounds gives convenient specializations of bound<>

    * snmalloc::capptr also has aliases for CapPtr<> itself

  All told, rather than `CapPtr<T, CBChunk>`, we now expect client code to read
  `capptr::Chunk<T>` in almost all cases (and this is just an alias for the
  appropriate `CapPtr<T, bounds<...>>` type).  When the bound<>s themselves are
  necessary, as when calling capptr_bound, we expect that they will almost
  always be pronounced using an alias (e.g., `capptr::bounds::Alloc`).

* Chase consequences.

* Prune old taxa and aliases that are no longer in use in snmalloc2.
2021-10-13 16:30:41 +01:00

73 lines
1.9 KiB
C++

#pragma once
#ifdef __cpp_concepts
# include "../ds/concept.h"
# include "../ds/ptrwrap.h"
# include "aal_consts.h"
# include <cstdint>
# include <utility>
namespace snmalloc
{
/**
* AALs must advertise the bit vector of supported features, their name,
* machine word size, and an upper bound on the address space size
*/
template<typename AAL>
concept ConceptAAL_static_members = requires()
{
typename std::integral_constant<uint64_t, AAL::aal_features>;
typename std::integral_constant<int, AAL::aal_name>;
typename std::integral_constant<std::size_t, AAL::bits>;
typename std::integral_constant<std::size_t, AAL::address_bits>;
};
/**
* AALs provide a prefetch operation.
*/
template<typename AAL>
concept ConceptAAL_prefetch = requires(void *ptr)
{
{ AAL::prefetch(ptr) } noexcept -> ConceptSame<void>;
};
/**
* AALs provide a notion of high-precision timing.
*/
template<typename AAL>
concept ConceptAAL_tick = requires()
{
{ AAL::tick() } noexcept -> ConceptSame<uint64_t>;
};
template<typename AAL>
concept ConceptAAL_capptr_methods =
requires(capptr::Chunk<void> auth, capptr::AllocFull<void> ret, size_t sz)
{
/**
* Produce a pointer with reduced authority from a more privilged pointer.
* The resulting pointer will have base at auth's address and length of
* exactly sz. auth+sz must not exceed auth's limit.
*/
{ AAL::template capptr_bound<void, capptr::bounds::Chunk>(auth, sz) }
noexcept
-> ConceptSame<capptr::Chunk<void>>;
/**
* Construct a copy of auth with its target set to that of ret.
*/
{ AAL::capptr_rebound(auth, ret) } noexcept
-> ConceptSame<capptr::Chunk<void>>;
};
template<typename AAL>
concept ConceptAAL =
ConceptAAL_static_members<AAL> &&
ConceptAAL_prefetch<AAL> &&
ConceptAAL_tick<AAL> &&
ConceptAAL_capptr_methods<AAL>;
} // namespace snmalloc
#endif