1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

Kernel: Use a FixedArray for VMObject::m_physical_pages

This makes VMObject 8 bytes smaller since we can use the array size as
the page count.

The size() is now also computed from the page count instead of being
a separate value. This makes sizes always be a multiple of PAGE_SIZE,
which is sane.
This commit is contained in:
Andreas Kling 2019-08-07 20:12:50 +02:00
parent 5096eaa845
commit b67200dfea
5 changed files with 19 additions and 39 deletions

View file

@ -2,7 +2,7 @@
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
#include <AK/Vector.h>
#include <AK/FixedArray.h>
#include <AK/Weakable.h>
#include <Kernel/Lock.h>
@ -21,25 +21,20 @@ public:
virtual bool is_anonymous() const { return false; }
virtual bool is_inode() const { return false; }
int page_count() const { return m_size / PAGE_SIZE; }
const Vector<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
Vector<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
size_t page_count() const { return m_physical_pages.size(); }
const FixedArray<RefPtr<PhysicalPage>>& physical_pages() const { return m_physical_pages; }
FixedArray<RefPtr<PhysicalPage>>& physical_pages() { return m_physical_pages; }
size_t size() const { return m_size; }
size_t size() const { return m_physical_pages.size() * PAGE_SIZE; }
protected:
enum ShouldFillPhysicalPages {
No = 0,
Yes
};
VMObject(size_t, ShouldFillPhysicalPages);
explicit VMObject(size_t);
explicit VMObject(const VMObject&);
template<typename Callback>
void for_each_region(Callback);
size_t m_size { 0 };
Vector<RefPtr<PhysicalPage>> m_physical_pages;
FixedArray<RefPtr<PhysicalPage>> m_physical_pages;
private:
VMObject& operator=(const VMObject&) = delete;