summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-10 08:16:13 +0200
committerbunnei <bunneidev@gmail.com>2021-05-06 01:40:51 +0200
commitcfa7b9256371e689e51ab17fd1e564c556889e1a (patch)
tree91a02f61893336d72ad083c966d899b478a748f0
parenthle: kernel: Refactor several threads/events/sharedmemory to use slab heaps. (diff)
downloadyuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.gz
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.bz2
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.lz
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.xz
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.tar.zst
yuzu-cfa7b9256371e689e51ab17fd1e564c556889e1a.zip
Diffstat (limited to '')
-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) {
}
void KernelCore::Initialize() {
+ slab_heap_container = std::make_unique<SlabHeapContainer>();
impl->Initialize(*this);
}
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:
template <typename T>
KSlabHeap<T>& SlabHeap() {
if constexpr (std::is_same_v<T, Process>) {
- return slab_heap_Process;
+ return slab_heap_container->process;
} else if constexpr (std::is_same_v<T, KThread>) {
- return slab_heap_KThread;
+ return slab_heap_container->thread;
} else if constexpr (std::is_same_v<T, KEvent>) {
- return slab_heap_KEvent;
+ return slab_heap_container->event;
} else if constexpr (std::is_same_v<T, KSharedMemory>) {
- return slab_heap_KSharedMemory;
+ return slab_heap_container->shared_memory;
} else if constexpr (std::is_same_v<T, KLinkedListNode>) {
- return slab_heap_KLinkedListNode;
+ return slab_heap_container->linked_list_node;
}
}
@@ -301,11 +301,16 @@ private:
bool exception_exited{};
private:
- KSlabHeap<Process> slab_heap_Process;
- KSlabHeap<KThread> slab_heap_KThread;
- KSlabHeap<KEvent> slab_heap_KEvent;
- KSlabHeap<KSharedMemory> slab_heap_KSharedMemory;
- KSlabHeap<KLinkedListNode> slab_heap_KLinkedListNode;
+ /// Helper to encapsulate all slab heaps in a single heap allocated container
+ struct SlabHeapContainer {
+ KSlabHeap<Process> process;
+ KSlabHeap<KThread> thread;
+ KSlabHeap<KEvent> event;
+ KSlabHeap<KSharedMemory> shared_memory;
+ KSlabHeap<KLinkedListNode> linked_list_node;
+ };
+
+ std::unique_ptr<SlabHeapContainer> slab_heap_container;
};
} // namespace Kernel