@@ -867,44 +867,33 @@ namespace snmalloc
867867
868868 SNMALLOC_FAST_PATH void handle_dealloc_remote (Remote* p)
869869 {
870- Superslab* super = Superslab::get (p);
870+ if (likely (p->trunc_target_id () == get_trunc_id ()))
871+ {
872+ // Destined for my slabs
873+ Superslab* super = Superslab::get (p);
871874
872875#ifdef CHECK_CLIENT
873- if (p->trunc_target_id () != (super->get_allocator ()->trunc_id ()))
874- error (" Detected memory corruption. Potential use-after-free" );
876+ if (p->trunc_target_id () != (super->get_allocator ()->trunc_id ()))
877+ error (" Detected memory corruption. Potential use-after-free" );
875878#endif
876- if (likely (super->get_kind () == Super))
877- {
878- if (likely (super->get_allocator () == public_state ()))
879+ // Guard against remote queues that have colliding IDs
880+ SNMALLOC_ASSERT (super->get_allocator () == public_state ());
881+
882+ if (likely (p->sizeclass () < NUM_SMALL_CLASSES))
879883 {
884+ SNMALLOC_ASSERT (super->get_kind () == Super);
880885 small_dealloc_offseted (super, p, p->sizeclass ());
881- return ;
882886 }
883- }
884- handle_dealloc_remote_slow (p);
885- }
886-
887- SNMALLOC_SLOW_PATH void handle_dealloc_remote_slow (Remote* p)
888- {
889- Superslab* super = Superslab::get (p);
890- if (likely (super->get_kind () == Medium))
891- {
892- if (likely (super->get_allocator () == public_state ()))
887+ else
893888 {
889+ SNMALLOC_ASSERT (super->get_kind () == Medium);
894890 void * start = remove_cache_friendly_offset (p, p->sizeclass ());
895891 medium_dealloc (Mediumslab::get (p), start, p->sizeclass ());
896892 }
897- else
898- {
899- // Queue for remote dealloc elsewhere.
900- remote.dealloc (p->trunc_target_id (), p, p->sizeclass ());
901- }
902893 }
903894 else
904895 {
905- SNMALLOC_ASSERT (likely (p->trunc_target_id () != get_trunc_id ()));
906- SNMALLOC_ASSERT (likely (super->get_allocator () != public_state ()));
907- // Queue for remote dealloc elsewhere.
896+ // Merely routing
908897 remote.dealloc (p->trunc_target_id (), p, p->sizeclass ());
909898 }
910899 }
0 commit comments