From 3ea2ee1a401ada153db3076affc0dea996e2f1f5 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 1 Jul 2024 14:19:46 -0400 Subject: [PATCH] kernel: Use "final" more in the VM and x86 paging classes. Since we always compile the kernel with modern GCC, we might as well take advantage of modern C++ features. In addition to providing a sanity check, "final" is also an optimization, since it allows the compiler to devirtualize calls made directly to a "final" class. Change-Id: Iedb0ee8834637771f5b6113c17342dbf67e99042 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7826 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- .../kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp | 2 +- .../kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h | 2 +- .../kernel/arch/x86/paging/32bit/X86PagingStructures32Bit.h | 2 +- .../kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.h | 2 +- src/system/kernel/arch/x86/paging/X86VMTranslationMap.h | 5 ----- src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp | 2 +- src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h | 2 +- .../kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.h | 2 +- .../x86/paging/x86_physical_page_mapper_large_memory.cpp | 4 ++-- src/system/kernel/cache/vnode_store.h | 2 +- src/system/kernel/vm/VMAnonymousCache.h | 2 +- src/system/kernel/vm/VMAnonymousNoSwapCache.h | 2 +- src/system/kernel/vm/VMDeviceCache.h | 2 +- src/system/kernel/vm/VMKernelAddressSpace.h | 2 +- src/system/kernel/vm/VMNullCache.h | 2 +- src/system/kernel/vm/VMUserAddressSpace.h | 2 +- 16 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp index c75942adf4..181baa9d3e 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp +++ b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.cpp @@ -47,7 +47,7 @@ using X86LargePhysicalPageMapper::PhysicalPageSlot; // #pragma mark - X86PagingMethod32Bit::PhysicalPageSlotPool -struct X86PagingMethod32Bit::PhysicalPageSlotPool +struct X86PagingMethod32Bit::PhysicalPageSlotPool final : X86LargePhysicalPageMapper::PhysicalPageSlotPool { public: virtual ~PhysicalPageSlotPool(); diff --git a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h index 96cb50605c..7af0f1d3e8 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h +++ b/src/system/kernel/arch/x86/paging/32bit/X86PagingMethod32Bit.h @@ -15,7 +15,7 @@ class TranslationMapPhysicalPageMapper; class X86PhysicalPageMapper; -class X86PagingMethod32Bit : public X86PagingMethod { +class X86PagingMethod32Bit final : public X86PagingMethod { public: X86PagingMethod32Bit(); virtual ~X86PagingMethod32Bit(); diff --git a/src/system/kernel/arch/x86/paging/32bit/X86PagingStructures32Bit.h b/src/system/kernel/arch/x86/paging/32bit/X86PagingStructures32Bit.h index 12c5f96b9e..09d910788a 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86PagingStructures32Bit.h +++ b/src/system/kernel/arch/x86/paging/32bit/X86PagingStructures32Bit.h @@ -10,7 +10,7 @@ #include "paging/X86PagingStructures.h" -struct X86PagingStructures32Bit : X86PagingStructures { +struct X86PagingStructures32Bit final : X86PagingStructures { page_directory_entry* pgdir_virt; X86PagingStructures32Bit(); diff --git a/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.h b/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.h index db996594fa..1ea2130fb3 100644 --- a/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.h +++ b/src/system/kernel/arch/x86/paging/32bit/X86VMTranslationMap32Bit.h @@ -12,7 +12,7 @@ struct X86PagingStructures32Bit; -struct X86VMTranslationMap32Bit : X86VMTranslationMap { +struct X86VMTranslationMap32Bit final : X86VMTranslationMap { X86VMTranslationMap32Bit(); virtual ~X86VMTranslationMap32Bit(); diff --git a/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h b/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h index bf632151b5..b863f8b964 100644 --- a/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h +++ b/src/system/kernel/arch/x86/paging/X86VMTranslationMap.h @@ -9,11 +9,6 @@ #include -#if __GNUC__ < 4 -#define final -#endif - - #define PAGE_INVALIDATE_CACHE_SIZE 64 diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp index 69e069e12c..05991c7b0c 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp @@ -351,7 +351,7 @@ private: // #pragma mark - PhysicalPageSlotPool -struct X86PagingMethodPAE::PhysicalPageSlotPool +struct X86PagingMethodPAE::PhysicalPageSlotPool final : X86LargePhysicalPageMapper::PhysicalPageSlotPool { public: virtual ~PhysicalPageSlotPool(); diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h index 2bb951aec8..bcc25f6696 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.h @@ -23,7 +23,7 @@ class TranslationMapPhysicalPageMapper; class X86PhysicalPageMapper; -class X86PagingMethodPAE : public X86PagingMethod { +class X86PagingMethodPAE final : public X86PagingMethod { public: X86PagingMethodPAE(); virtual ~X86PagingMethodPAE(); diff --git a/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.h b/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.h index 2873fc144c..c630be1619 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.h +++ b/src/system/kernel/arch/x86/paging/pae/X86VMTranslationMapPAE.h @@ -15,7 +15,7 @@ struct X86PagingStructuresPAE; -struct X86VMTranslationMapPAE : X86VMTranslationMap { +struct X86VMTranslationMapPAE final : X86VMTranslationMap { X86VMTranslationMapPAE(); virtual ~X86VMTranslationMapPAE(); diff --git a/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp b/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp index 87d9df27ea..aa699fb308 100644 --- a/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp +++ b/src/system/kernel/arch/x86/paging/x86_physical_page_mapper_large_memory.cpp @@ -90,7 +90,7 @@ private: // #pragma mark - -class LargeMemoryTranslationMapPhysicalPageMapper +class LargeMemoryTranslationMapPhysicalPageMapper final : public TranslationMapPhysicalPageMapper { public: LargeMemoryTranslationMapPhysicalPageMapper(); @@ -115,7 +115,7 @@ private: }; -class LargeMemoryPhysicalPageMapper : public X86PhysicalPageMapper { +class LargeMemoryPhysicalPageMapper final : public X86PhysicalPageMapper { public: LargeMemoryPhysicalPageMapper(); diff --git a/src/system/kernel/cache/vnode_store.h b/src/system/kernel/cache/vnode_store.h index 8f3b3ed4e2..4c1b5c73eb 100644 --- a/src/system/kernel/cache/vnode_store.h +++ b/src/system/kernel/cache/vnode_store.h @@ -13,7 +13,7 @@ struct file_cache_ref; -class VMVnodeCache : public VMCache { +class VMVnodeCache final : public VMCache { public: status_t Init(struct vnode* vnode, uint32 allocationFlags); diff --git a/src/system/kernel/vm/VMAnonymousCache.h b/src/system/kernel/vm/VMAnonymousCache.h index b5172beb55..741d2a283a 100644 --- a/src/system/kernel/vm/VMAnonymousCache.h +++ b/src/system/kernel/vm/VMAnonymousCache.h @@ -31,7 +31,7 @@ extern "C" { } -class VMAnonymousCache : public VMCache { +class VMAnonymousCache final : public VMCache { public: virtual ~VMAnonymousCache(); diff --git a/src/system/kernel/vm/VMAnonymousNoSwapCache.h b/src/system/kernel/vm/VMAnonymousNoSwapCache.h index ee92338448..3754c044cb 100644 --- a/src/system/kernel/vm/VMAnonymousNoSwapCache.h +++ b/src/system/kernel/vm/VMAnonymousNoSwapCache.h @@ -13,7 +13,7 @@ #include -class VMAnonymousNoSwapCache : public VMCache { +class VMAnonymousNoSwapCache final : public VMCache { public: virtual ~VMAnonymousNoSwapCache(); diff --git a/src/system/kernel/vm/VMDeviceCache.h b/src/system/kernel/vm/VMDeviceCache.h index a1998ca45e..4ef1fe8e1a 100644 --- a/src/system/kernel/vm/VMDeviceCache.h +++ b/src/system/kernel/vm/VMDeviceCache.h @@ -13,7 +13,7 @@ #include -class VMDeviceCache : public VMCache { +class VMDeviceCache final : public VMCache { public: status_t Init(addr_t baseAddress, uint32 allocationFlags); diff --git a/src/system/kernel/vm/VMKernelAddressSpace.h b/src/system/kernel/vm/VMKernelAddressSpace.h index 489c0173ef..1543cd1ef2 100644 --- a/src/system/kernel/vm/VMKernelAddressSpace.h +++ b/src/system/kernel/vm/VMKernelAddressSpace.h @@ -14,7 +14,7 @@ struct ObjectCache; -struct VMKernelAddressSpace : VMAddressSpace { +struct VMKernelAddressSpace final : VMAddressSpace { public: VMKernelAddressSpace(team_id id, addr_t base, size_t size); diff --git a/src/system/kernel/vm/VMNullCache.h b/src/system/kernel/vm/VMNullCache.h index f6aefba29b..8699d6cc4e 100644 --- a/src/system/kernel/vm/VMNullCache.h +++ b/src/system/kernel/vm/VMNullCache.h @@ -13,7 +13,7 @@ #include -class VMNullCache : public VMCache { +class VMNullCache final : public VMCache { public: status_t Init(uint32 allocationFlags); diff --git a/src/system/kernel/vm/VMUserAddressSpace.h b/src/system/kernel/vm/VMUserAddressSpace.h index 8f9c918c0d..ff5ae5341e 100644 --- a/src/system/kernel/vm/VMUserAddressSpace.h +++ b/src/system/kernel/vm/VMUserAddressSpace.h @@ -11,7 +11,7 @@ #include "VMUserArea.h" -struct VMUserAddressSpace : VMAddressSpace { +struct VMUserAddressSpace final : VMAddressSpace { public: VMUserAddressSpace(team_id id, addr_t base, size_t size);