NFC: Further disentangle chunkmap and pagemap

- Make GlobalPagemapTemplate and ExternalGlobalPagemap generic in the type of
  the pagemap they're encapsulating.

  We're going to want to use these for other kinds of pagemaps in the near
  future.

- Rename snmalloc_pagemap_global_get to snmalloc_chunkmap_global_get.

- Rename GlobalPagemap to GlobalChunkmap.
This commit is contained in:
Nathaniel Filardo
2021-01-08 18:05:45 +00:00
committed by Matthew Parkinson
parent 8da12f5af8
commit 6250428c3d
5 changed files with 87 additions and 81 deletions

View File

@@ -10,10 +10,13 @@ int main()
# define SNMALLOC_EXPOSE_PAGEMAP 1
# include <override/malloc.cc>
using ExternalChunkmap =
ExternalGlobalPagemapTemplate<ChunkmapPagemap, snmalloc_chunkmap_global_get>;
int main()
{
auto& p = ExternalGlobalPagemap::pagemap();
auto& global = GlobalPagemap::pagemap();
auto& p = ExternalChunkmap::pagemap();
auto& global = GlobalChunkmap::pagemap();
SNMALLOC_CHECK(&p == &global);
// Get a valid heap address
uintptr_t addr = reinterpret_cast<uintptr_t>(malloc(42));

View File

@@ -24,9 +24,9 @@ extern "C" void* enclave_malloc(size_t);
extern "C" void enclave_free(void*);
extern "C" void*
enclave_snmalloc_pagemap_global_get(snmalloc::PagemapConfig const**);
enclave_snmalloc_chunkmap_global_get(snmalloc::PagemapConfig const**);
extern "C" void*
host_snmalloc_pagemap_global_get(snmalloc::PagemapConfig const**);
host_snmalloc_chunkmap_global_get(snmalloc::PagemapConfig const**);
using namespace snmalloc;
int main()
@@ -47,8 +47,8 @@ int main()
// Call these functions to trigger asserts if the cast-to-self doesn't work.
const PagemapConfig* c;
enclave_snmalloc_pagemap_global_get(&c);
host_snmalloc_pagemap_global_get(&c);
enclave_snmalloc_chunkmap_global_get(&c);
host_snmalloc_chunkmap_global_get(&c);
auto a = host_malloc(128);
auto b = enclave_malloc(128);