AddressSpace: use Backend to access Pagemap
And do so by type, rather than by value. While here, introduce a C++20 concept for this Backend-offered proxy and adjust the template parameters appropriately. This will be useful for the process sandbox code, which needs to mediate stores to the pagemap, but can provide a read-only view.
This commit is contained in:
committed by
Nathaniel Wesley Filardo
parent
7eb8769950
commit
70c3e00df7
@@ -377,7 +377,7 @@ namespace snmalloc
|
||||
{
|
||||
auto p = message_queue().peek();
|
||||
auto& entry =
|
||||
SharedStateHandle::get_meta_data(snmalloc::address_cast(p));
|
||||
SharedStateHandle::Pagemap::get_meta_data(snmalloc::address_cast(p));
|
||||
|
||||
auto r = message_queue().dequeue(key_global);
|
||||
|
||||
@@ -538,7 +538,8 @@ namespace snmalloc
|
||||
|
||||
SNMALLOC_FAST_PATH void dealloc_local_object(void* p)
|
||||
{
|
||||
auto entry = SharedStateHandle::get_meta_data(snmalloc::address_cast(p));
|
||||
auto entry =
|
||||
SharedStateHandle::Pagemap::get_meta_data(snmalloc::address_cast(p));
|
||||
if (likely(dealloc_local_object_fast(entry, p, entropy)))
|
||||
return;
|
||||
|
||||
@@ -664,8 +665,8 @@ namespace snmalloc
|
||||
{
|
||||
bool need_post = true; // Always going to post, so ignore.
|
||||
auto n = p->atomic_read_next(key_global);
|
||||
auto& entry =
|
||||
SharedStateHandle::get_meta_data(snmalloc::address_cast(p));
|
||||
auto& entry = SharedStateHandle::Pagemap::get_meta_data(
|
||||
snmalloc::address_cast(p));
|
||||
handle_dealloc_remote(entry, p, need_post);
|
||||
p = n;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,8 @@ namespace snmalloc
|
||||
std::cout << "Remote dealloc post" << p << " size " << alloc_size(p)
|
||||
<< std::endl;
|
||||
#endif
|
||||
MetaEntry entry = SharedStateHandle::get_meta_data(address_cast(p));
|
||||
MetaEntry entry =
|
||||
SharedStateHandle::Pagemap::get_meta_data(address_cast(p));
|
||||
local_cache.remote_dealloc_cache.template dealloc<sizeof(CoreAlloc)>(
|
||||
entry.get_remote()->trunc_id(), CapPtr<void, CBAlloc>(p), key_global);
|
||||
post_remote_cache();
|
||||
@@ -472,7 +473,7 @@ namespace snmalloc
|
||||
// in thread local state.
|
||||
|
||||
const MetaEntry& entry =
|
||||
SharedStateHandle::get_meta_data(address_cast(p));
|
||||
SharedStateHandle::Pagemap::get_meta_data(address_cast(p));
|
||||
if (likely(local_cache.remote_allocator == entry.get_remote()))
|
||||
{
|
||||
if (likely(CoreAlloc::dealloc_local_object_fast(
|
||||
@@ -582,7 +583,8 @@ namespace snmalloc
|
||||
// To handle this case we require the uninitialised pagemap contain an
|
||||
// entry for the first chunk of memory, that states it represents a large
|
||||
// object, so we can pull the check for null off the fast path.
|
||||
MetaEntry entry = SharedStateHandle::get_meta_data(address_cast(p_raw));
|
||||
MetaEntry entry =
|
||||
SharedStateHandle::Pagemap::get_meta_data(address_cast(p_raw));
|
||||
|
||||
if (likely(entry.get_remote() != SharedStateHandle::fake_large_remote))
|
||||
return sizeclass_to_size(entry.get_sizeclass());
|
||||
@@ -608,7 +610,8 @@ namespace snmalloc
|
||||
#ifndef SNMALLOC_PASS_THROUGH
|
||||
// TODO bring back the CHERI bits. Wes to review if required.
|
||||
MetaEntry entry =
|
||||
SharedStateHandle::template get_meta_data<true>(address_cast(p_raw));
|
||||
SharedStateHandle::Pagemap::template get_meta_data<true>(
|
||||
address_cast(p_raw));
|
||||
auto sizeclass = entry.get_sizeclass();
|
||||
if (likely(entry.get_remote() != SharedStateHandle::fake_large_remote))
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace snmalloc
|
||||
{
|
||||
auto [first, last] = list[i].extract_segment(key);
|
||||
MetaEntry entry =
|
||||
SharedStateHandle::get_meta_data(address_cast(first));
|
||||
SharedStateHandle::Pagemap::get_meta_data(address_cast(first));
|
||||
entry.get_remote()->enqueue(first, last, key);
|
||||
sent_something = true;
|
||||
}
|
||||
@@ -117,7 +117,8 @@ namespace snmalloc
|
||||
// Use the next N bits to spread out remote deallocs in our own
|
||||
// slot.
|
||||
auto r = resend.take(key);
|
||||
MetaEntry entry = SharedStateHandle::get_meta_data(address_cast(r));
|
||||
MetaEntry entry =
|
||||
SharedStateHandle::Pagemap::get_meta_data(address_cast(r));
|
||||
auto i = entry.get_remote()->trunc_id();
|
||||
size_t slot = get_slot<allocator_size>(i, post_round);
|
||||
list[slot].add(r, key);
|
||||
|
||||
@@ -107,7 +107,8 @@ namespace snmalloc
|
||||
<< std::endl;
|
||||
#endif
|
||||
MetaEntry entry{meta, remote, sizeclass};
|
||||
SharedStateHandle::set_meta_data(address_cast(slab), slab_size, entry);
|
||||
SharedStateHandle::Pagemap::set_meta_data(
|
||||
address_cast(slab), slab_size, entry);
|
||||
return {slab, meta};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user