@@ -50,7 +50,7 @@ namespace snmalloc
5050 return p;
5151 }
5252
53- static void * failure (size_t size)
53+ static void * failure (size_t size) noexcept
5454 {
5555 UNUSED (size);
5656 // If we are here, then the allocation failed.
@@ -401,25 +401,25 @@ namespace snmalloc
401401 * the stack as often closing over the arguments would cause less good
402402 * codegen.
403403 */
404- template <typename Action, typename ... Args>
404+ template <bool noexc, typename Action, typename ... Args>
405405 SNMALLOC_FAST_PATH decltype (auto )
406- handle_message_queue(Action action, Args... args)
406+ handle_message_queue(Action action, Args... args) noexcept (noexc)
407407 {
408408 // Inline the empty check, but not necessarily the full queue handling.
409409 if (SNMALLOC_LIKELY (!has_messages ()))
410410 {
411411 return action (args...);
412412 }
413413
414- return handle_message_queue_slow (action, args...);
414+ return handle_message_queue_slow<noexc> (action, args...);
415415 }
416416
417417 /* *
418418 * Process remote frees into this allocator.
419419 */
420- template <typename Action, typename ... Args>
420+ template <bool noexc, typename Action, typename ... Args>
421421 SNMALLOC_SLOW_PATH decltype (auto )
422- handle_message_queue_slow(Action action, Args... args)
422+ handle_message_queue_slow(Action action, Args... args) noexcept (noexc)
423423 {
424424 bool need_post = false ;
425425 size_t bytes_freed = 0 ;
@@ -602,7 +602,8 @@ namespace snmalloc
602602 * required. It is defaulted to do nothing.
603603 */
604604 template <typename Conts = Uninit, typename CheckInit = CheckInitNoOp>
605- SNMALLOC_FAST_PATH ALLOCATOR void * alloc (size_t size)
605+ SNMALLOC_FAST_PATH ALLOCATOR void *
606+ alloc (size_t size) noexcept (noexcept (Conts::failure(0 )))
606607 {
607608 // Perform the - 1 on size, so that zero wraps around and ends up on
608609 // slow path.
@@ -621,7 +622,8 @@ namespace snmalloc
621622 * Fast allocation for small objects.
622623 */
623624 template <typename Conts, typename CheckInit>
624- SNMALLOC_FAST_PATH void * small_alloc (size_t size)
625+ SNMALLOC_FAST_PATH void *
626+ small_alloc (size_t size) noexcept (noexcept (Conts::failure(0 )))
625627 {
626628 auto domesticate =
627629 [this ](freelist::QueuePtr p) SNMALLOC_FAST_PATH_LAMBDA {
@@ -637,7 +639,7 @@ namespace snmalloc
637639 return finish_alloc<Conts>(p, size);
638640 }
639641
640- return handle_message_queue (
642+ return handle_message_queue< noexcept ( Conts::failure ( 0 ))> (
641643 [](
642644 Allocator* alloc,
643645 smallsizeclass_t sizeclass,
@@ -661,8 +663,8 @@ namespace snmalloc
661663 * register.
662664 */
663665 template <typename Conts, typename CheckInit>
664- static SNMALLOC_SLOW_PATH void *
665- alloc_not_small ( size_t size, Allocator* self)
666+ static SNMALLOC_SLOW_PATH void * alloc_not_small (
667+ size_t size, Allocator* self) noexcept ( noexcept (Conts::failure( 0 )) )
666668 {
667669 if (size == 0 )
668670 {
@@ -672,7 +674,7 @@ namespace snmalloc
672674 return self->small_alloc <Conts, CheckInit>(1 );
673675 }
674676
675- return self->handle_message_queue (
677+ return self->template handle_message_queue < noexcept ( Conts::failure ( 0 ))> (
676678 [](Allocator* self, size_t size) SNMALLOC_FAST_PATH_LAMBDA {
677679 return CheckInit::check_init (
678680 [self, size]() SNMALLOC_FAST_PATH_LAMBDA {
@@ -739,7 +741,9 @@ namespace snmalloc
739741
740742 template <typename Conts, typename CheckInit>
741743 SNMALLOC_FAST_PATH void * small_refill (
742- smallsizeclass_t sizeclass, freelist::Iter<>& fast_free_list, size_t size)
744+ smallsizeclass_t sizeclass,
745+ freelist::Iter<>& fast_free_list,
746+ size_t size) noexcept (noexcept (Conts::failure(0 )))
743747 {
744748 void * result = Config::SecondaryAllocator::allocate (
745749 [size]() -> stl::Pair<size_t , size_t > {
@@ -809,7 +813,9 @@ namespace snmalloc
809813
810814 template <typename Conts, typename CheckInit>
811815 SNMALLOC_SLOW_PATH void * small_refill_slow (
812- smallsizeclass_t sizeclass, freelist::Iter<>& fast_free_list, size_t size)
816+ smallsizeclass_t sizeclass,
817+ freelist::Iter<>& fast_free_list,
818+ size_t size) noexcept (noexcept (Conts::failure(0 )))
813819 {
814820 return CheckInit::check_init (
815821 [this , size, sizeclass, &fast_free_list]() SNMALLOC_FAST_PATH_LAMBDA {
@@ -994,7 +1000,7 @@ namespace snmalloc
9941000 * deallocation to the other allocators.
9951001 ***************************************************************************/
9961002 template <typename CheckInit = CheckInitNoOp>
997- SNMALLOC_FAST_PATH void dealloc (void * p_raw)
1003+ SNMALLOC_FAST_PATH void dealloc (void * p_raw) noexcept
9981004 {
9991005#ifdef __CHERI_PURE_CAPABILITY__
10001006 /*
@@ -1043,7 +1049,7 @@ namespace snmalloc
10431049
10441050 SNMALLOC_FAST_PATH void dealloc_local_object (
10451051 CapPtr<void , capptr::bounds::Alloc> p,
1046- const typename Config::PagemapEntry& entry)
1052+ const typename Config::PagemapEntry& entry) noexcept
10471053 {
10481054 auto meta = entry.get_slab_metadata ();
10491055
@@ -1078,7 +1084,7 @@ namespace snmalloc
10781084 SNMALLOC_SLOW_PATH void dealloc_local_object_slow (
10791085 capptr::Alloc<void > p,
10801086 const PagemapEntry& entry,
1081- BackendSlabMetadata* meta)
1087+ BackendSlabMetadata* meta) noexcept
10821088 {
10831089 // TODO: Handle message queue on this path?
10841090
@@ -1273,8 +1279,8 @@ namespace snmalloc
12731279 }
12741280
12751281 template <typename CheckInit>
1276- SNMALLOC_FAST_PATH void
1277- dealloc_remote ( const PagemapEntry& entry, capptr::Alloc<void > p_tame)
1282+ SNMALLOC_FAST_PATH void dealloc_remote (
1283+ const PagemapEntry& entry, capptr::Alloc<void > p_tame) noexcept
12781284 {
12791285 if (SNMALLOC_LIKELY (entry.is_owned ()))
12801286 {
@@ -1327,8 +1333,8 @@ namespace snmalloc
13271333 * as we might acquire the originating allocator.
13281334 */
13291335 template <typename CheckInit>
1330- SNMALLOC_SLOW_PATH void
1331- dealloc_remote_slow ( const PagemapEntry& entry, capptr::Alloc<void > p)
1336+ SNMALLOC_SLOW_PATH void dealloc_remote_slow (
1337+ const PagemapEntry& entry, capptr::Alloc<void > p) noexcept
13321338 {
13331339 CheckInit::check_init (
13341340 [this , &entry, p]() SNMALLOC_FAST_PATH_LAMBDA {
@@ -1344,7 +1350,7 @@ namespace snmalloc
13441350
13451351 post ();
13461352 },
1347- [](Allocator* a, void * p) {
1353+ [](Allocator* a, void * p) SNMALLOC_FAST_PATH_LAMBDA {
13481354 // Recheck what kind of dealloc we should do in case the allocator
13491355 // we get from lazy_init is the originating allocator.
13501356 a->dealloc (p); // TODO don't double count statistics
@@ -1385,7 +1391,7 @@ namespace snmalloc
13851391 // Process incoming message queue
13861392 // Loop as normally only processes a batch
13871393 while (has_messages ())
1388- handle_message_queue ([]() {});
1394+ handle_message_queue< true > ([]() {});
13891395 }
13901396
13911397 auto & key = freelist::Object::key_root;
0 commit comments