If you're creating a new allocator and the pagemap comes from a library
that exports the pagemap accessor function but not the pagemap symbol,
you need to be able to replace this.
The PAL can now advertise that it supports aligned allocation. If it
does not, then the memory provider will do the alignment for it.
This change still leaves the PAL responsible for systematic testing, but
it should now be much easier to lift that out.
Replace them with some very simple constexpr things. This is what the
code used to look like, but it appears that I fundamentally
misunderstood why it didn't work. This version should be a lot more
maintainable.
- Rename MemoryProviderState to PAL to reflect what is now is.
- Hide calls to the PAL's low memory functions behind something that
returns a default value if they're not implemented.
This does not deallocate memory until the OS tells us that we are short
on memory, then tries to decommit all of the cached chunks (except for
the first page, used for the linked lists).
Nowhere near enough testing to commit to master yet!
Introduce a `OnePastEnd` option for the pointer immediately after the
end of the allocation. This simplifies some of the logic in callers,
where they wants to say 'is base + length safe to use?'.
Also restructure some of the other logic somewhat.
Introduce a wrapper that ensure various fields of meta data, represent
valid indexes into the the address space, and not beyond the current
slab/superslab.
If a sizeclass in the metadata is corrupted, then this can be used to
force an index beyond the end of these tables. This extends the tables
to the next power of two, and uses a mask on the index, so they are
always either a valid piece of data, or zero.
The union in Metaslab provides no benefit in size, as the single byte
it effectively saves will be removed due to padding.
By removing the union, we get stronger properties over sizeclass, and
remove an out-of-bounds access.