summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2021-04-09 23:16:13 -0700
committerGravatar bunnei2021-05-05 16:40:51 -0700
commitcfa7b9256371e689e51ab17fd1e564c556889e1a (patch)
tree91a02f61893336d72ad083c966d899b478a748f0 /src/core/hle/kernel
parenthle: kernel: Refactor several threads/events/sharedmemory to use slab heaps. (diff)
downloadyuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.gz
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.xz
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.zip
hle: kernel: Move slab heaps to their own container.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/kernel.cpp1
-rw-r--r--src/core/hle/kernel/kernel.h25
2 files changed, 16 insertions, 10 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 1b7ba39f4..472c71cf1 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) {
692} 692}
693 693
694void KernelCore::Initialize() { 694void KernelCore::Initialize() {
695 slab_heap_container = std::make_unique<SlabHeapContainer>();
695 impl->Initialize(*this); 696 impl->Initialize(*this);
696} 697}
697 698
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 855bb590a..e494fe9f3 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -260,15 +260,15 @@ public:
260 template <typename T> 260 template <typename T>
261 KSlabHeap<T>& SlabHeap() { 261 KSlabHeap<T>& SlabHeap() {
262 if constexpr (std::is_same_v<T, Process>) { 262 if constexpr (std::is_same_v<T, Process>) {
263 return slab_heap_Process; 263 return slab_heap_container->process;
264 } else if constexpr (std::is_same_v<T, KThread>) { 264 } else if constexpr (std::is_same_v<T, KThread>) {
265 return slab_heap_KThread; 265 return slab_heap_container->thread;
266 } else if constexpr (std::is_same_v<T, KEvent>) { 266 } else if constexpr (std::is_same_v<T, KEvent>) {
267 return slab_heap_KEvent; 267 return slab_heap_container->event;
268 } else if constexpr (std::is_same_v<T, KSharedMemory>) { 268 } else if constexpr (std::is_same_v<T, KSharedMemory>) {
269 return slab_heap_KSharedMemory; 269 return slab_heap_container->shared_memory;
270 } else if constexpr (std::is_same_v<T, KLinkedListNode>) { 270 } else if constexpr (std::is_same_v<T, KLinkedListNode>) {
271 return slab_heap_KLinkedListNode; 271 return slab_heap_container->linked_list_node;
272 } 272 }
273 } 273 }
274 274
@@ -301,11 +301,16 @@ private:
301 bool exception_exited{}; 301 bool exception_exited{};
302 302
303private: 303private:
304 KSlabHeap<Process> slab_heap_Process; 304 /// Helper to encapsulate all slab heaps in a single heap allocated container
305 KSlabHeap<KThread> slab_heap_KThread; 305 struct SlabHeapContainer {
306 KSlabHeap<KEvent> slab_heap_KEvent; 306 KSlabHeap<Process> process;
307 KSlabHeap<KSharedMemory> slab_heap_KSharedMemory; 307 KSlabHeap<KThread> thread;
308 KSlabHeap<KLinkedListNode> slab_heap_KLinkedListNode; 308 KSlabHeap<KEvent> event;
309 KSlabHeap<KSharedMemory> shared_memory;
310 KSlabHeap<KLinkedListNode> linked_list_node;
311 };
312
313 std::unique_ptr<SlabHeapContainer> slab_heap_container;
309}; 314};
310 315
311} // namespace Kernel 316} // namespace Kernel