2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

hle: kernel: Move slab heaps to their own container.

This commit is contained in:
bunnei 2021-04-09 23:16:13 -07:00
parent 89edbe8aa2
commit cfa7b92563
2 changed files with 16 additions and 10 deletions

View file

@ -692,6 +692,7 @@ void KernelCore::SetMulticore(bool is_multicore) {
} }
void KernelCore::Initialize() { void KernelCore::Initialize() {
slab_heap_container = std::make_unique<SlabHeapContainer>();
impl->Initialize(*this); impl->Initialize(*this);
} }

View file

@ -260,15 +260,15 @@ public:
template <typename T> template <typename T>
KSlabHeap<T>& SlabHeap() { KSlabHeap<T>& SlabHeap() {
if constexpr (std::is_same_v<T, Process>) { 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>) { } 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>) { } 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>) { } 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>) { } 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{}; bool exception_exited{};
private: private:
KSlabHeap<Process> slab_heap_Process; /// Helper to encapsulate all slab heaps in a single heap allocated container
KSlabHeap<KThread> slab_heap_KThread; struct SlabHeapContainer {
KSlabHeap<KEvent> slab_heap_KEvent; KSlabHeap<Process> process;
KSlabHeap<KSharedMemory> slab_heap_KSharedMemory; KSlabHeap<KThread> thread;
KSlabHeap<KLinkedListNode> slab_heap_KLinkedListNode; KSlabHeap<KEvent> event;
KSlabHeap<KSharedMemory> shared_memory;
KSlabHeap<KLinkedListNode> linked_list_node;
};
std::unique_ptr<SlabHeapContainer> slab_heap_container;
}; };
} // namespace Kernel } // namespace Kernel