mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:37:36 +00:00
Kernel: Rename various *VMObject::create*() => try_create()
try_*() implies that it can fail (and they all return RefPtr with nullptr signalling failure.)
This commit is contained in:
parent
af8c74a328
commit
88d490566f
19 changed files with 35 additions and 35 deletions
|
@ -55,7 +55,7 @@ RefPtr<VMObject> AnonymousVMObject::clone()
|
|||
return adopt_ref_if_nonnull(new (nothrow) AnonymousVMObject(*this));
|
||||
}
|
||||
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size, AllocationStrategy commit)
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::try_create_with_size(size_t size, AllocationStrategy commit)
|
||||
{
|
||||
if (commit == AllocationStrategy::Reserve || commit == AllocationStrategy::AllocateNow) {
|
||||
// We need to attempt to commit before actually creating the object
|
||||
|
@ -65,20 +65,20 @@ RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_size(size_t size, Alloc
|
|||
return adopt_ref_if_nonnull(new (nothrow) AnonymousVMObject(size, commit));
|
||||
}
|
||||
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_pages(NonnullRefPtrVector<PhysicalPage> physical_pages)
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::try_create_with_physical_pages(NonnullRefPtrVector<PhysicalPage> physical_pages)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) AnonymousVMObject(physical_pages));
|
||||
}
|
||||
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::create_with_physical_page(PhysicalPage& page)
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::try_create_with_physical_page(PhysicalPage& page)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) AnonymousVMObject(page));
|
||||
}
|
||||
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::create_for_physical_range(PhysicalAddress paddr, size_t size)
|
||||
RefPtr<AnonymousVMObject> AnonymousVMObject::try_create_for_physical_range(PhysicalAddress paddr, size_t size)
|
||||
{
|
||||
if (paddr.offset(size) < paddr) {
|
||||
dbgln("Shenanigans! create_for_physical_range({}, {}) would wrap around", paddr, size);
|
||||
dbgln("Shenanigans! try_create_for_physical_range({}, {}) would wrap around", paddr, size);
|
||||
return nullptr;
|
||||
}
|
||||
return adopt_ref_if_nonnull(new (nothrow) AnonymousVMObject(paddr, size));
|
||||
|
|
|
@ -21,10 +21,10 @@ class AnonymousVMObject final : public VMObject {
|
|||
public:
|
||||
virtual ~AnonymousVMObject() override;
|
||||
|
||||
static RefPtr<AnonymousVMObject> create_with_size(size_t, AllocationStrategy);
|
||||
static RefPtr<AnonymousVMObject> create_for_physical_range(PhysicalAddress paddr, size_t size);
|
||||
static RefPtr<AnonymousVMObject> create_with_physical_page(PhysicalPage& page);
|
||||
static RefPtr<AnonymousVMObject> create_with_physical_pages(NonnullRefPtrVector<PhysicalPage>);
|
||||
static RefPtr<AnonymousVMObject> try_create_with_size(size_t, AllocationStrategy);
|
||||
static RefPtr<AnonymousVMObject> try_create_for_physical_range(PhysicalAddress paddr, size_t size);
|
||||
static RefPtr<AnonymousVMObject> try_create_with_physical_page(PhysicalPage& page);
|
||||
static RefPtr<AnonymousVMObject> try_create_with_physical_pages(NonnullRefPtrVector<PhysicalPage>);
|
||||
virtual RefPtr<VMObject> clone() override;
|
||||
|
||||
RefPtr<PhysicalPage> allocate_committed_page(size_t);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
RefPtr<ContiguousVMObject> ContiguousVMObject::create_with_size(size_t size, size_t physical_alignment)
|
||||
RefPtr<ContiguousVMObject> ContiguousVMObject::try_create_with_size(size_t size, size_t physical_alignment)
|
||||
{
|
||||
auto contiguous_physical_pages = MM.allocate_contiguous_supervisor_physical_pages(size, physical_alignment);
|
||||
if (contiguous_physical_pages.is_empty())
|
||||
|
|
|
@ -15,7 +15,7 @@ class ContiguousVMObject final : public VMObject {
|
|||
public:
|
||||
virtual ~ContiguousVMObject() override;
|
||||
|
||||
static RefPtr<ContiguousVMObject> create_with_size(size_t, size_t physical_alignment = PAGE_SIZE);
|
||||
static RefPtr<ContiguousVMObject> try_create_with_size(size_t, size_t physical_alignment = PAGE_SIZE);
|
||||
|
||||
private:
|
||||
explicit ContiguousVMObject(size_t, NonnullRefPtrVector<PhysicalPage>&);
|
||||
|
|
|
@ -631,7 +631,7 @@ OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, Str
|
|||
auto range = kernel_page_directory().range_allocator().allocate_anywhere(size);
|
||||
if (!range.has_value())
|
||||
return {};
|
||||
auto vmobject = ContiguousVMObject::create_with_size(size, physical_alignment);
|
||||
auto vmobject = ContiguousVMObject::try_create_with_size(size, physical_alignment);
|
||||
if (!vmobject) {
|
||||
kernel_page_directory().range_allocator().deallocate(range.value());
|
||||
return {};
|
||||
|
@ -642,7 +642,7 @@ OwnPtr<Region> MemoryManager::allocate_contiguous_kernel_region(size_t size, Str
|
|||
OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, StringView name, Region::Access access, AllocationStrategy strategy, Region::Cacheable cacheable)
|
||||
{
|
||||
VERIFY(!(size % PAGE_SIZE));
|
||||
auto vm_object = AnonymousVMObject::create_with_size(size, strategy);
|
||||
auto vm_object = AnonymousVMObject::try_create_with_size(size, strategy);
|
||||
if (!vm_object)
|
||||
return {};
|
||||
ScopedSpinLock lock(s_mm_lock);
|
||||
|
@ -654,7 +654,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(size_t size, StringView nam
|
|||
|
||||
OwnPtr<Region> MemoryManager::allocate_kernel_region(PhysicalAddress paddr, size_t size, StringView name, Region::Access access, Region::Cacheable cacheable)
|
||||
{
|
||||
auto vm_object = AnonymousVMObject::create_for_physical_range(paddr, size);
|
||||
auto vm_object = AnonymousVMObject::try_create_for_physical_range(paddr, size);
|
||||
if (!vm_object)
|
||||
return {};
|
||||
VERIFY(!(size % PAGE_SIZE));
|
||||
|
@ -667,7 +667,7 @@ OwnPtr<Region> MemoryManager::allocate_kernel_region(PhysicalAddress paddr, size
|
|||
|
||||
OwnPtr<Region> MemoryManager::allocate_kernel_region_identity(PhysicalAddress paddr, size_t size, StringView name, Region::Access access, Region::Cacheable cacheable)
|
||||
{
|
||||
auto vm_object = AnonymousVMObject::create_for_physical_range(paddr, size);
|
||||
auto vm_object = AnonymousVMObject::try_create_for_physical_range(paddr, size);
|
||||
if (!vm_object)
|
||||
return {};
|
||||
VERIFY(!(size % PAGE_SIZE));
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
RefPtr<PrivateInodeVMObject> PrivateInodeVMObject::create_with_inode(Inode& inode)
|
||||
RefPtr<PrivateInodeVMObject> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
{
|
||||
return adopt_ref_if_nonnull(new (nothrow) PrivateInodeVMObject(inode, inode.size()));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class PrivateInodeVMObject final : public InodeVMObject {
|
|||
public:
|
||||
virtual ~PrivateInodeVMObject() override;
|
||||
|
||||
static RefPtr<PrivateInodeVMObject> create_with_inode(Inode&);
|
||||
static RefPtr<PrivateInodeVMObject> try_create_with_inode(Inode&);
|
||||
virtual RefPtr<VMObject> clone() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Kernel {
|
|||
|
||||
RefPtr<ScatterGatherList> ScatterGatherList::create(AsyncBlockDeviceRequest& request, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size)
|
||||
{
|
||||
auto vm_object = AnonymousVMObject::create_with_physical_pages(allocated_pages);
|
||||
auto vm_object = AnonymousVMObject::try_create_with_physical_pages(allocated_pages);
|
||||
if (!vm_object)
|
||||
return {};
|
||||
return adopt_ref_if_nonnull(new (nothrow) ScatterGatherList(vm_object.release_nonnull(), request, device_block_size));
|
||||
|
|
|
@ -161,7 +161,7 @@ Region& Space::allocate_split_region(const Region& source_region, const Range& r
|
|||
KResultOr<Region*> Space::allocate_region(Range const& range, StringView name, int prot, AllocationStrategy strategy)
|
||||
{
|
||||
VERIFY(range.is_valid());
|
||||
auto vmobject = AnonymousVMObject::create_with_size(range.size(), strategy);
|
||||
auto vmobject = AnonymousVMObject::try_create_with_size(range.size(), strategy);
|
||||
if (!vmobject)
|
||||
return ENOMEM;
|
||||
auto region = Region::create_user_accessible(m_process, range, vmobject.release_nonnull(), 0, KString::try_create(name), prot_to_region_access_flags(prot), Region::Cacheable::Yes, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue