mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
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:
parent
aa92adeedf
commit
7c3b6b10e4
Notes:
sideshowbarker
2024-07-19 00:16:26 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7c3b6b10e42
7 changed files with 10 additions and 23 deletions
|
@ -42,8 +42,9 @@ int Process::sys$purge(int mode)
|
||||||
NonnullRefPtrVector<PurgeableVMObject> vmobjects;
|
NonnullRefPtrVector<PurgeableVMObject> vmobjects;
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
MM.for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
|
MM.for_each_vmobject([&](auto& vmobject) {
|
||||||
vmobjects.append(vmobject);
|
if (vmobject.is_purgeable())
|
||||||
|
vmobjects.append(static_cast<PurgeableVMObject&>(vmobject));
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -55,8 +56,9 @@ int Process::sys$purge(int mode)
|
||||||
NonnullRefPtrVector<InodeVMObject> vmobjects;
|
NonnullRefPtrVector<InodeVMObject> vmobjects;
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
MM.for_each_vmobject_of_type<InodeVMObject>([&](auto& vmobject) {
|
MM.for_each_vmobject([&](auto& vmobject) {
|
||||||
vmobjects.append(vmobject);
|
if (vmobject.is_inode())
|
||||||
|
vmobjects.append(static_cast<InodeVMObject&>(vmobject));
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
|
||||||
|
|
|
@ -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()
|
|
||||||
|
|
|
@ -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()
|
|
||||||
|
|
|
@ -509,8 +509,10 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
|
||||||
if (!page) {
|
if (!page) {
|
||||||
// We didn't have a single free physical page. Let's try to free something up!
|
// 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.
|
// First, we look for a purgeable VMObject in the volatile state.
|
||||||
for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
|
for_each_vmobject([&](auto& vmobject) {
|
||||||
int purged_page_count = vmobject.purge_with_interrupts_disabled({});
|
if (!vmobject.is_purgeable())
|
||||||
|
return IterationDecision::Continue;
|
||||||
|
int purged_page_count = static_cast<PurgeableVMObject&>(vmobject).purge_with_interrupts_disabled({});
|
||||||
if (purged_page_count) {
|
if (purged_page_count) {
|
||||||
klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &vmobject << "}";
|
klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &vmobject << "}";
|
||||||
page = find_free_user_physical_page();
|
page = find_free_user_physical_page();
|
||||||
|
|
|
@ -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()
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/InlineLinkedList.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/TypeCasts.h>
|
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <AK/Weakable.h>
|
#include <AK/Weakable.h>
|
||||||
#include <Kernel/Lock.h>
|
#include <Kernel/Lock.h>
|
||||||
|
|
Loading…
Reference in a new issue