mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:18:11 +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:
parent
5096eaa845
commit
b67200dfea
5 changed files with 19 additions and 39 deletions
|
@ -3,27 +3,25 @@
|
|||
|
||||
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size)
|
||||
{
|
||||
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
||||
return adopt(*new AnonymousVMObject(size));
|
||||
}
|
||||
|
||||
NonnullRefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
|
||||
{
|
||||
size = ceil_div(size, PAGE_SIZE) * PAGE_SIZE;
|
||||
return adopt(*new AnonymousVMObject(paddr, size));
|
||||
}
|
||||
|
||||
AnonymousVMObject::AnonymousVMObject(size_t size)
|
||||
: VMObject(size, ShouldFillPhysicalPages::Yes)
|
||||
: VMObject(size)
|
||||
{
|
||||
}
|
||||
|
||||
AnonymousVMObject::AnonymousVMObject(PhysicalAddress paddr, size_t size)
|
||||
: VMObject(size, ShouldFillPhysicalPages::No)
|
||||
: VMObject(size)
|
||||
{
|
||||
for (size_t i = 0; i < size; i += PAGE_SIZE)
|
||||
m_physical_pages.append(PhysicalPage::create(paddr.offset(i), false, false));
|
||||
ASSERT(m_physical_pages.size() == page_count());
|
||||
ASSERT(paddr.page_base() == paddr.get());
|
||||
for (size_t i = 0; i < page_count(); ++i)
|
||||
physical_pages()[i] = PhysicalPage::create(paddr.offset(i * PAGE_SIZE), false, false);
|
||||
}
|
||||
|
||||
AnonymousVMObject::AnonymousVMObject(const AnonymousVMObject& other)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue