saving current changes
This commit is contained in:
72
docs/EuroSys/Paper/drawio/jemalloc_malloc_pseudo_code
Normal file
72
docs/EuroSys/Paper/drawio/jemalloc_malloc_pseudo_code
Normal file
@@ -0,0 +1,72 @@
|
||||
static void *
|
||||
os_pages_map(void *addr, size_t size, size_t alignment, bool *commit) {
|
||||
assert(ALIGNMENT_ADDR2BASE(addr, os_page) == (vaddr_t)addr);
|
||||
assert(ALIGNMENT_CEILING(size, os_page) == size);
|
||||
assert(size != 0);
|
||||
/* Non-NULL addresses don't work in CheriABI */
|
||||
if (addr != NULL)
|
||||
return (NULL);
|
||||
|
||||
if (os_overcommits) {
|
||||
*commit = true;
|
||||
}
|
||||
|
||||
void *ret;
|
||||
|
||||
ret = MALLOCCHERI(size);
|
||||
|
||||
assert(ret != NULL);
|
||||
|
||||
if (addr != NULL && ret != addr) {
|
||||
/*
|
||||
* We succeeded in mapping memory, but not in the right place.
|
||||
*/
|
||||
os_pages_unmap(ret, size);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
pages_map(void *addr, size_t size, size_t alignment, bool *commit) {
|
||||
assert(alignment >= PAGE);
|
||||
assert(ALIGNMENT_ADDR2BASE(addr, alignment) == (vaddr_t)addr);
|
||||
|
||||
if (size & ~CHERI_REPRESENTABLE_ALIGNMENT_MASK(size))
|
||||
abort();
|
||||
|
||||
...
|
||||
|
||||
void *ret = MALLOCCHERI(size); // replaced instead of mmap
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static bool
|
||||
pages_commit_impl(void *addr, size_t size, bool commit) {
|
||||
assert(PAGE_ADDR2BASE(addr) == addr);
|
||||
assert(PAGE_CEILING(size) == size);
|
||||
|
||||
...
|
||||
|
||||
void *result = MALLOCCHERI(size); // replaced instead of mmap
|
||||
if (result != addr) {
|
||||
/*
|
||||
* We succeeded in mapping memory, but not in the right
|
||||
* place.
|
||||
*/
|
||||
os_pages_unmap(result, size);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
os_pages_unmap(void *addr, size_t size) {
|
||||
assert(ALIGNMENT_ADDR2BASE(addr, os_page) == (vaddr_t)addr);
|
||||
assert(ALIGNMENT_CEILING(size, os_page) == size);
|
||||
|
||||
FREECHERI(addr);
|
||||
}
|
||||
Reference in New Issue
Block a user