Kernel: Remove the limited use of AK::TypeTraits we had in the kernel

This was only used for VMObject and we can do without it there. This is
preparation for migrating to dynamic_cast-based helpers in userspace.
This commit is contained in:
Andreas Kling 2021-01-01 15:32:06 +01:00
parent aa92adeedf
commit 7c3b6b10e4
Notes: sideshowbarker 2024-07-19 00:16:26 +09:00
7 changed files with 10 additions and 23 deletions

View file

@ -42,8 +42,9 @@ int Process::sys$purge(int mode)
NonnullRefPtrVector<PurgeableVMObject> vmobjects;
{
InterruptDisabler disabler;
MM.for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
vmobjects.append(vmobject);
MM.for_each_vmobject([&](auto& vmobject) {
if (vmobject.is_purgeable())
vmobjects.append(static_cast<PurgeableVMObject&>(vmobject));
return IterationDecision::Continue;
});
}
@ -55,8 +56,9 @@ int Process::sys$purge(int mode)
NonnullRefPtrVector<InodeVMObject> vmobjects;
{
InterruptDisabler disabler;
MM.for_each_vmobject_of_type<InodeVMObject>([&](auto& vmobject) {
vmobjects.append(vmobject);
MM.for_each_vmobject([&](auto& vmobject) {
if (vmobject.is_inode())
vmobjects.append(static_cast<InodeVMObject&>(vmobject));
return IterationDecision::Continue;
});
}

View file

@ -57,7 +57,3 @@ private:
};
}
AK_BEGIN_TYPE_TRAITS(Kernel::AnonymousVMObject)
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_anonymous(); }
AK_END_TYPE_TRAITS()

View file

@ -52,7 +52,3 @@ private:
};
}
AK_BEGIN_TYPE_TRAITS(Kernel::ContiguousVMObject)
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_contiguous(); }
AK_END_TYPE_TRAITS()

View file

@ -67,7 +67,3 @@ protected:
};
}
AK_BEGIN_TYPE_TRAITS(Kernel::InodeVMObject)
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_inode(); }
AK_END_TYPE_TRAITS()

View file

@ -509,8 +509,10 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
if (!page) {
// We didn't have a single free physical page. Let's try to free something up!
// First, we look for a purgeable VMObject in the volatile state.
for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
int purged_page_count = vmobject.purge_with_interrupts_disabled({});
for_each_vmobject([&](auto& vmobject) {
if (!vmobject.is_purgeable())
return IterationDecision::Continue;
int purged_page_count = static_cast<PurgeableVMObject&>(vmobject).purge_with_interrupts_disabled({});
if (purged_page_count) {
klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &vmobject << "}";
page = find_free_user_physical_page();

View file

@ -65,7 +65,3 @@ private:
};
}
AK_BEGIN_TYPE_TRAITS(Kernel::PurgeableVMObject)
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_purgeable(); }
AK_END_TYPE_TRAITS()

View file

@ -29,7 +29,6 @@
#include <AK/InlineLinkedList.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/TypeCasts.h>
#include <AK/Vector.h>
#include <AK/Weakable.h>
#include <Kernel/Lock.h>