NFC: Introduce pointer domestication backend support

`capptr_domesticate<Backend>(Backend::LocalState*, CapPtr<T, B>)` is the
intended affordance for conversion to covert from a `CapPtr<T, B>` with
`B::wildness` `Wild` to a `CapPtr<>` with `B::with_wildness<Tame>` and thence
plumbed into the rest of the machinery.

David added the SFINAE wrapper so that `Backend`-s now don't need to implement a
domestication callback; instead, if the `Backend` does not provide a
`capptr_domesticate` function, a default, which just does an explicit type cast,
will be used instead.

This is not yet hooked into the rest of the tree.

Co-authored-by: David Chisnall <David.Chisnall@microsoft.com>
This commit is contained in:
Nathaniel Wesley Filardo
2021-08-16 21:03:29 +01:00
committed by Nathaniel Wesley Filardo
parent 7e53a2e82a
commit 1a608e6066
6 changed files with 133 additions and 1 deletions

View File

@@ -58,6 +58,24 @@ namespace snmalloc
concept ConceptBackendMetaRange =
ConceptBackendMeta<Meta> && ConceptBackendMeta_Range<Meta>;
/**
* The backend also defines domestication (that is, the difference between
* Tame and Wild CapPtr bounds). It exports the intended affordance for
* testing a Wild pointer and either returning nullptr or the original
* pointer, now Tame.
*/
template<typename Globals>
concept ConceptBackendDomestication =
requires(typename Globals::LocalState* ls,
capptr::AllocWild<void> ptr)
{
{ Globals::capptr_domesticate(ls, ptr) }
-> ConceptSame<capptr::Alloc<void>>;
{ Globals::capptr_domesticate(ls, ptr.template as_static<char>()) }
-> ConceptSame<capptr::Alloc<char>>;
};
class CommonConfig;
struct Flags;
@@ -89,6 +107,7 @@ namespace snmalloc
typename Globals::GlobalPoolState;
{ Globals::pool() } -> ConceptSame<typename Globals::GlobalPoolState &>;
};
/**