diff --git a/src/mem/largealloc.h b/src/mem/largealloc.h index b2cb998..62de9a6 100644 --- a/src/mem/largealloc.h +++ b/src/mem/largealloc.h @@ -12,7 +12,7 @@ namespace snmalloc { - template + template class MemoryProviderStateMixin; class Largeslab : public Baseslab @@ -22,7 +22,7 @@ namespace snmalloc private: template friend class MPMCStack; - template + template friend class MemoryProviderStateMixin; std::atomic next; @@ -44,10 +44,10 @@ namespace snmalloc // This represents the state that the large allcoator needs to add to the // global state of the allocator. This is currently stored in the memory // provider, so we add this in. - template - class MemoryProviderStateMixin : public MemoryProviderState + template + class MemoryProviderStateMixin : public PAL { - using MemoryProviderState::supports_low_memory_notification; + using PAL::supports_low_memory_notification; std::atomic_flag lock = ATOMIC_FLAG_INIT; size_t bump; size_t remaining; @@ -55,14 +55,12 @@ namespace snmalloc std::pair reserve_block() noexcept { size_t size = SUPERSLAB_SIZE; - void* r = ((MemoryProviderState*)this) - ->template reserve(&size, SUPERSLAB_SIZE); + void* r = ((PAL*)this)->template reserve(&size, SUPERSLAB_SIZE); if (size < SUPERSLAB_SIZE) error("out of memory"); - ((MemoryProviderState*)this) - ->template notify_using(r, OS_PAGE_SIZE); + ((PAL*)this)->template notify_using(r, OS_PAGE_SIZE); return std::make_pair(r, size); } @@ -104,8 +102,7 @@ namespace snmalloc // the stack. if (slab->get_kind() != Decommitted) { - MemoryProviderState::notify_not_using( - ((char*)slab) + OS_PAGE_SIZE, decommit_size); + PAL::notify_not_using(((char*)slab) + OS_PAGE_SIZE, decommit_size); } // Once we've removed these from the stack, there will be no // concurrent accesses and removal should have established a @@ -128,7 +125,7 @@ namespace snmalloc ALWAYSINLINE uint64_t low_mem_epoch( std::enable_if_t = 0) { - return MemoryProviderState::low_memory_epoch(); + return PAL::low_memory_epoch(); } /** @@ -187,7 +184,7 @@ namespace snmalloc auto page_start = bits::align_down((size_t)p, OS_PAGE_SIZE); auto page_end = bits::align_up((size_t)p + size, OS_PAGE_SIZE); - ((MemoryProviderState*)this) + ((PAL*)this) ->template notify_using( (void*)page_start, page_end - page_start); @@ -202,7 +199,7 @@ namespace snmalloc ALWAYSINLINE uint64_t low_memory_epoch() { - return low_mem_epoch(); + return low_mem_epoch(); } ALWAYSINLINE void lazy_decommit_if_needed()