SP: introduce AAL, PAL methods as per design doc

These capture the primitive architectural operations we are going to use.  At
the moment, since all AALs and PALs are not StrictProvenance, the only
implementations are stubs that just subvert the type system (but give us
something to compile against, going forward).
This commit is contained in:
Nathaniel Filardo
2020-11-21 03:23:05 +00:00
committed by Nathaniel Wesley Filardo
parent c5aff8ed74
commit 268ef2c059
3 changed files with 91 additions and 2 deletions

View File

@@ -69,6 +69,30 @@ namespace snmalloc
// Used to keep Superslab metadata committed.
static constexpr size_t OS_PAGE_SIZE = Pal::page_size;
/**
* Perform platform-specific adjustment of return pointers.
*
* This is here, rather than in every PAL proper, merely to minimize
* disruption to PALs for platforms that do not support StrictProvenance AALs.
*/
template<typename PAL = Pal, typename AAL = Aal, typename T, capptr_bounds B>
static SNMALLOC_FAST_PATH typename std::enable_if_t<
!aal_supports<StrictProvenance, AAL>,
CapPtr<T, capptr_export_type<B>()>>
capptr_export(CapPtr<T, B> p)
{
return CapPtr<T, capptr_export_type<B>()>(p.unsafe_capptr);
}
template<typename PAL = Pal, typename AAL = Aal, typename T, capptr_bounds B>
static SNMALLOC_FAST_PATH typename std::enable_if_t<
aal_supports<StrictProvenance, AAL>,
CapPtr<T, capptr_export_type<B>()>>
capptr_export(CapPtr<T, B> p)
{
return PAL::capptr_export(p);
}
/**
* A convenience wrapper that avoids the need to litter unsafe accesses with
* every call to PAL::zero.