From 5151a3b93405c1565441b6b45a6dc6bb858e6dbe Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 11 Dec 2020 13:58:22 -0800 Subject: [PATCH] ircd::ios: Inline additional handler related definitions. --- include/ircd/ios.h | 66 +++++++++++++++++++++++++++++++++++++++++++++- ircd/ios.cc | 57 +-------------------------------------- 2 files changed, 66 insertions(+), 57 deletions(-) diff --git a/include/ircd/ios.h b/include/ircd/ios.h index 2fe1b0390..cfed73d5f 100644 --- a/include/ircd/ios.h +++ b/include/ircd/ios.h @@ -119,7 +119,7 @@ struct ircd::ios::descriptor descriptor(const string_view &name, const decltype(allocator) & = default_allocator, const decltype(deallocator) & = default_deallocator, - const bool &continuation = false); + const bool &continuation = false) noexcept; descriptor(descriptor &&) = delete; descriptor(const descriptor &) = delete; @@ -267,6 +267,43 @@ const // ircd::ios::handler // +[[gnu::hot]] +inline void +ircd::ios::handler::deallocate(handler *const &handler, + void *const &ptr, + const size_t &size) +noexcept +{ + assert(handler && handler->descriptor); + auto &descriptor(*handler->descriptor); + + assert(descriptor.deallocator); + descriptor.deallocator(*handler, ptr, size); + + assert(descriptor.stats); + auto &stats(*descriptor.stats); + stats.free_bytes += size; + ++stats.frees; +} + +[[gnu::hot]] +inline void * +ircd::ios::handler::allocate(handler *const &handler, + const size_t &size) +{ + assert(handler && handler->descriptor); + auto &descriptor(*handler->descriptor); + + assert(descriptor.stats); + auto &stats(*descriptor.stats); + stats.alloc_bytes += size; + ++stats.allocs; + + assert(descriptor.allocator); + return descriptor.allocator(*handler, size); +} + +[[gnu::hot]] inline void ircd::ios::handler::enqueue(handler *const &handler) noexcept @@ -291,6 +328,7 @@ noexcept }; } +[[gnu::hot]] inline bool ircd::ios::handler::continuation(handler *const &handler) noexcept @@ -300,6 +338,32 @@ noexcept return descriptor.continuation; } +// +// ios::descriptor +// + +[[gnu::hot]] +inline void +ircd::ios::descriptor::default_deallocator(handler &handler, + void *const &ptr, + const size_t &size) +noexcept +{ + #ifdef __clang__ + ::operator delete(ptr); + #else + ::operator delete(ptr, size); + #endif +} + +[[gnu::hot]] +inline void * +ircd::ios::descriptor::default_allocator(handler &handler, + const size_t &size) +{ + return ::operator new(size); +} + // // ircd::ios // diff --git a/ircd/ios.cc b/ircd/ios.cc index f75fe10c6..5fda3f87a 100644 --- a/ircd/ios.cc +++ b/ircd/ios.cc @@ -91,6 +91,7 @@ ircd::ios::descriptor::descriptor(const string_view &name, const decltype(allocator) &allocator, const decltype(deallocator) &deallocator, const bool &continuation) +noexcept :name { name @@ -130,28 +131,6 @@ noexcept assert(!stats || stats->alloc_bytes == stats->free_bytes); } -[[gnu::hot]] -void -ircd::ios::descriptor::default_deallocator(handler &handler, - void *const &ptr, - const size_t &size) -noexcept -{ - #ifdef __clang__ - ::operator delete(ptr); - #else - ::operator delete(ptr, size); - #endif -} - -[[gnu::hot]] -void * -ircd::ios::descriptor::default_allocator(handler &handler, - const size_t &size) -{ - return ::operator new(size); -} - // // descriptor::stats // @@ -315,40 +294,6 @@ noexcept }; } -[[gnu::hot]] -void -ircd::ios::handler::deallocate(handler *const &handler, - void *const &ptr, - const size_t &size) -noexcept -{ - assert(handler && handler->descriptor); - auto &descriptor(*handler->descriptor); - - descriptor.deallocator(*handler, ptr, size); - - assert(descriptor.stats); - auto &stats(*descriptor.stats); - stats.free_bytes += size; - ++stats.frees; -} - -[[gnu::hot]] -void * -ircd::ios::handler::allocate(handler *const &handler, - const size_t &size) -{ - assert(handler && handler->descriptor); - auto &descriptor(*handler->descriptor); - - assert(descriptor.stats); - auto &stats(*descriptor.stats); - stats.alloc_bytes += size; - ++stats.allocs; - - return descriptor.allocator(*handler, size); -} - // // ios.h //