From cfa7b9256371e689e51ab17fd1e564c556889e1a Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 9 Apr 2021 23:16:13 -0700 Subject: [PATCH] hle: kernel: Move slab heaps to their own container. --- src/core/hle/kernel/kernel.cpp | 1 + src/core/hle/kernel/kernel.h | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 1b7ba39f44..472c71cf1d 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -692,6 +692,7 @@ void KernelCore::SetMulticore(bool is_multicore) { } void KernelCore::Initialize() { + slab_heap_container = std::make_unique(); impl->Initialize(*this); } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 855bb590a1..e494fe9f39 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -260,15 +260,15 @@ public: template KSlabHeap& SlabHeap() { if constexpr (std::is_same_v) { - return slab_heap_Process; + return slab_heap_container->process; } else if constexpr (std::is_same_v) { - return slab_heap_KThread; + return slab_heap_container->thread; } else if constexpr (std::is_same_v) { - return slab_heap_KEvent; + return slab_heap_container->event; } else if constexpr (std::is_same_v) { - return slab_heap_KSharedMemory; + return slab_heap_container->shared_memory; } else if constexpr (std::is_same_v) { - return slab_heap_KLinkedListNode; + return slab_heap_container->linked_list_node; } } @@ -301,11 +301,16 @@ private: bool exception_exited{}; private: - KSlabHeap slab_heap_Process; - KSlabHeap slab_heap_KThread; - KSlabHeap slab_heap_KEvent; - KSlabHeap slab_heap_KSharedMemory; - KSlabHeap slab_heap_KLinkedListNode; + /// Helper to encapsulate all slab heaps in a single heap allocated container + struct SlabHeapContainer { + KSlabHeap process; + KSlabHeap thread; + KSlabHeap event; + KSlabHeap shared_memory; + KSlabHeap linked_list_node; + }; + + std::unique_ptr slab_heap_container; }; } // namespace Kernel