@@ -403,7 +403,8 @@ namespace snmalloc
403403 * by this thread, or handling the final deallocation onto a slab,
404404 * so it can be reused by other threads.
405405 */
406- SNMALLOC_SLOW_PATH void dealloc_local_object_slow (const MetaEntry& entry)
406+ SNMALLOC_SLOW_PATH void
407+ dealloc_local_object_slow (const MetaslabMetaEntry& entry)
407408 {
408409 // TODO: Handle message queue on this path?
409410
@@ -486,19 +487,20 @@ namespace snmalloc
486487 [local_state](freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
487488 return capptr_domesticate<SharedStateHandle>(local_state, p);
488489 };
489- auto cb = [this , &need_post](freelist::HeadPtr msg)
490- SNMALLOC_FAST_PATH_LAMBDA {
490+ auto cb = [this ,
491+ &need_post](freelist::HeadPtr msg) SNMALLOC_FAST_PATH_LAMBDA {
491492#ifdef SNMALLOC_TRACING
492- std::cout << " Handling remote" << std::endl;
493+ std::cout << " Handling remote" << std::endl;
493494#endif
494495
495- auto & entry = SharedStateHandle::Pagemap::get_metaentry (
496- snmalloc::address_cast (msg));
496+ auto & entry =
497+ SharedStateHandle::Pagemap::template get_metaentry<MetaslabMetaEntry>(
498+ snmalloc::address_cast (msg));
497499
498- handle_dealloc_remote (entry, msg.as_void (), need_post);
500+ handle_dealloc_remote (entry, msg.as_void (), need_post);
499501
500- return true ;
501- };
502+ return true ;
503+ };
502504
503505 if constexpr (SharedStateHandle::Options.QueueHeadsAreTame )
504506 {
@@ -532,7 +534,7 @@ namespace snmalloc
532534 * need_post will be set to true, if capacity is exceeded.
533535 */
534536 void handle_dealloc_remote (
535- const MetaEntry & entry,
537+ const MetaslabMetaEntry & entry,
536538 CapPtr<void , capptr::bounds::Alloc> p,
537539 bool & need_post)
538540 {
@@ -672,16 +674,18 @@ namespace snmalloc
672674 SNMALLOC_FAST_PATH void
673675 dealloc_local_object (CapPtr<void , capptr::bounds::Alloc> p)
674676 {
675- const MetaEntry& entry =
676- SharedStateHandle::Pagemap::get_metaentry (snmalloc::address_cast (p));
677+ // MetaEntry-s seen here are expected to have meaningful Remote pointers
678+ auto & entry =
679+ SharedStateHandle::Pagemap::template get_metaentry<MetaslabMetaEntry>(
680+ snmalloc::address_cast (p));
677681 if (SNMALLOC_LIKELY (dealloc_local_object_fast (entry, p, entropy)))
678682 return ;
679683
680684 dealloc_local_object_slow (entry);
681685 }
682686
683687 SNMALLOC_FAST_PATH static bool dealloc_local_object_fast (
684- const MetaEntry & entry,
688+ const MetaslabMetaEntry & entry,
685689 CapPtr<void , capptr::bounds::Alloc> p,
686690 LocalEntropy& entropy)
687691 {
@@ -786,8 +790,8 @@ namespace snmalloc
786790 auto [slab, meta] = SharedStateHandle::alloc_chunk (
787791 get_backend_local_state (),
788792 slab_size,
789- public_state (),
790- sizeclass_t::from_small_class (sizeclass));
793+ MetaslabMetaEntry::encode (
794+ public_state (), sizeclass_t::from_small_class (sizeclass) ));
791795
792796 if (slab == nullptr )
793797 {
@@ -840,8 +844,9 @@ namespace snmalloc
840844 {
841845 bool need_post = true ; // Always going to post, so ignore.
842846 auto n_tame = p_tame->atomic_read_next (key_global, domesticate);
843- auto & entry = SharedStateHandle::Pagemap::get_metaentry (
844- snmalloc::address_cast (p_tame));
847+ const MetaslabMetaEntry& entry =
848+ SharedStateHandle::Pagemap::template get_metaentry<
849+ MetaslabMetaEntry>(snmalloc::address_cast (p_tame));
845850 handle_dealloc_remote (entry, p_tame.as_void (), need_post);
846851 p_tame = n_tame;
847852 }
0 commit comments