Kernel: Convert VMObject & subclasses to east-const style

This commit is contained in:
Andreas Kling 2021-07-22 00:02:34 +02:00
parent 1610669519
commit 9e15708aa0
12 changed files with 41 additions and 41 deletions

View file

@ -25,7 +25,7 @@ RefPtr<VMObject> AnonymousVMObject::try_clone()
size_t need_cow_pages = 0; size_t need_cow_pages = 0;
// We definitely need to commit non-volatile areas // We definitely need to commit non-volatile areas
for_each_nonvolatile_range([&](const VolatilePageRange& nonvolatile_range) { for_each_nonvolatile_range([&](VolatilePageRange const& nonvolatile_range) {
need_cow_pages += nonvolatile_range.count; need_cow_pages += nonvolatile_range.count;
}); });
@ -125,7 +125,7 @@ AnonymousVMObject::AnonymousVMObject(NonnullRefPtrVector<PhysicalPage> physical_
} }
} }
AnonymousVMObject::AnonymousVMObject(const AnonymousVMObject& other) AnonymousVMObject::AnonymousVMObject(AnonymousVMObject const& other)
: VMObject(other) : VMObject(other)
, m_volatile_ranges_cache({ 0, page_count() }) // do *not* clone this , m_volatile_ranges_cache({ 0, page_count() }) // do *not* clone this
, m_volatile_ranges_cache_dirty(true) // do *not* clone this , m_volatile_ranges_cache_dirty(true) // do *not* clone this
@ -178,7 +178,7 @@ int AnonymousVMObject::purge_with_interrupts_disabled(Badge<MemoryManager>)
return purge_impl(); return purge_impl();
} }
void AnonymousVMObject::set_was_purged(const VolatilePageRange& range) void AnonymousVMObject::set_was_purged(VolatilePageRange const& range)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
for (auto* purgeable_ranges : m_purgeable_ranges) for (auto* purgeable_ranges : m_purgeable_ranges)
@ -189,7 +189,7 @@ int AnonymousVMObject::purge_impl()
{ {
int purged_page_count = 0; int purged_page_count = 0;
ScopedSpinLock lock(m_lock); ScopedSpinLock lock(m_lock);
for_each_volatile_range([&](const auto& range) { for_each_volatile_range([&](auto const& range) {
int purged_in_range = 0; int purged_in_range = 0;
auto range_end = range.base + range.count; auto range_end = range.base + range.count;
for (size_t i = range.base; i < range_end; i++) { for (size_t i = range.base; i < range_end; i++) {
@ -261,7 +261,7 @@ bool AnonymousVMObject::is_any_volatile() const
return false; return false;
} }
size_t AnonymousVMObject::remove_lazy_commit_pages(const VolatilePageRange& range) size_t AnonymousVMObject::remove_lazy_commit_pages(VolatilePageRange const& range)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
@ -286,14 +286,14 @@ void AnonymousVMObject::update_volatile_cache()
VERIFY(m_volatile_ranges_cache_dirty); VERIFY(m_volatile_ranges_cache_dirty);
m_volatile_ranges_cache.clear(); m_volatile_ranges_cache.clear();
for_each_nonvolatile_range([&](const VolatilePageRange& range) { for_each_nonvolatile_range([&](VolatilePageRange const& range) {
m_volatile_ranges_cache.add_unchecked(range); m_volatile_ranges_cache.add_unchecked(range);
}); });
m_volatile_ranges_cache_dirty = false; m_volatile_ranges_cache_dirty = false;
} }
void AnonymousVMObject::range_made_volatile(const VolatilePageRange& range) void AnonymousVMObject::range_made_volatile(VolatilePageRange const& range)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
@ -305,7 +305,7 @@ void AnonymousVMObject::range_made_volatile(const VolatilePageRange& range)
// and also adjust the m_unused_committed_pages for each such page. // and also adjust the m_unused_committed_pages for each such page.
// Take into account all the other views as well. // Take into account all the other views as well.
size_t uncommit_page_count = 0; size_t uncommit_page_count = 0;
for_each_volatile_range([&](const auto& r) { for_each_volatile_range([&](auto const& r) {
auto intersected = range.intersected(r); auto intersected = range.intersected(r);
if (!intersected.is_empty()) { if (!intersected.is_empty()) {
uncommit_page_count += remove_lazy_commit_pages(intersected); uncommit_page_count += remove_lazy_commit_pages(intersected);
@ -324,13 +324,13 @@ void AnonymousVMObject::range_made_volatile(const VolatilePageRange& range)
m_volatile_ranges_cache_dirty = true; m_volatile_ranges_cache_dirty = true;
} }
void AnonymousVMObject::range_made_nonvolatile(const VolatilePageRange&) void AnonymousVMObject::range_made_nonvolatile(VolatilePageRange const&)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
m_volatile_ranges_cache_dirty = true; m_volatile_ranges_cache_dirty = true;
} }
size_t AnonymousVMObject::count_needed_commit_pages_for_nonvolatile_range(const VolatilePageRange& range) size_t AnonymousVMObject::count_needed_commit_pages_for_nonvolatile_range(VolatilePageRange const& range)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
VERIFY(!range.is_empty()); VERIFY(!range.is_empty());
@ -348,7 +348,7 @@ size_t AnonymousVMObject::count_needed_commit_pages_for_nonvolatile_range(const
return need_commit_pages; return need_commit_pages;
} }
size_t AnonymousVMObject::mark_committed_pages_for_nonvolatile_range(const VolatilePageRange& range, size_t mark_total) size_t AnonymousVMObject::mark_committed_pages_for_nonvolatile_range(VolatilePageRange const& range, size_t mark_total)
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
VERIFY(!range.is_empty()); VERIFY(!range.is_empty());

View file

@ -41,7 +41,7 @@ public:
bool is_any_volatile() const; bool is_any_volatile() const;
template<IteratorFunction<const VolatilePageRange&> F> template<IteratorFunction<VolatilePageRange const&> F>
IterationDecision for_each_volatile_range(F f) const IterationDecision for_each_volatile_range(F f) const
{ {
VERIFY(m_lock.is_locked()); VERIFY(m_lock.is_locked());
@ -61,7 +61,7 @@ public:
// immediately bail // immediately bail
return IterationDecision::Continue; return IterationDecision::Continue;
} }
for (const auto& r2 : purgeable_range2->volatile_ranges().ranges()) { for (auto const& r2 : purgeable_range2->volatile_ranges().ranges()) {
range = range.intersected(r2); range = range.intersected(r2);
if (range.is_empty()) if (range.is_empty())
break; break;
@ -79,11 +79,11 @@ public:
return IterationDecision::Continue; return IterationDecision::Continue;
} }
template<IteratorFunction<const VolatilePageRange&> F> template<IteratorFunction<VolatilePageRange const&> F>
IterationDecision for_each_nonvolatile_range(F f) const IterationDecision for_each_nonvolatile_range(F f) const
{ {
size_t base = 0; size_t base = 0;
for_each_volatile_range([&](const VolatilePageRange& volatile_range) { for_each_volatile_range([&](VolatilePageRange const& volatile_range) {
if (volatile_range.base == base) if (volatile_range.base == base)
return IterationDecision::Continue; return IterationDecision::Continue;
IterationDecision decision = f(VolatilePageRange { base, volatile_range.base - base }); IterationDecision decision = f(VolatilePageRange { base, volatile_range.base - base });
@ -97,7 +97,7 @@ public:
return IterationDecision::Continue; return IterationDecision::Continue;
} }
template<VoidFunction<const VolatilePageRange&> F> template<VoidFunction<VolatilePageRange const&> F>
IterationDecision for_each_volatile_range(F f) const IterationDecision for_each_volatile_range(F f) const
{ {
return for_each_volatile_range([&](auto& range) { return for_each_volatile_range([&](auto& range) {
@ -106,7 +106,7 @@ public:
}); });
} }
template<VoidFunction<const VolatilePageRange&> F> template<VoidFunction<VolatilePageRange const&> F>
IterationDecision for_each_nonvolatile_range(F f) const IterationDecision for_each_nonvolatile_range(F f) const
{ {
return for_each_nonvolatile_range([&](auto range) { return for_each_nonvolatile_range([&](auto range) {
@ -120,21 +120,21 @@ private:
explicit AnonymousVMObject(PhysicalAddress, size_t); explicit AnonymousVMObject(PhysicalAddress, size_t);
explicit AnonymousVMObject(PhysicalPage&); explicit AnonymousVMObject(PhysicalPage&);
explicit AnonymousVMObject(NonnullRefPtrVector<PhysicalPage>); explicit AnonymousVMObject(NonnullRefPtrVector<PhysicalPage>);
explicit AnonymousVMObject(const AnonymousVMObject&); explicit AnonymousVMObject(AnonymousVMObject const&);
virtual StringView class_name() const override { return "AnonymousVMObject"sv; } virtual StringView class_name() const override { return "AnonymousVMObject"sv; }
int purge_impl(); int purge_impl();
void update_volatile_cache(); void update_volatile_cache();
void set_was_purged(const VolatilePageRange&); void set_was_purged(VolatilePageRange const&);
size_t remove_lazy_commit_pages(const VolatilePageRange&); size_t remove_lazy_commit_pages(VolatilePageRange const&);
void range_made_volatile(const VolatilePageRange&); void range_made_volatile(VolatilePageRange const&);
void range_made_nonvolatile(const VolatilePageRange&); void range_made_nonvolatile(VolatilePageRange const&);
size_t count_needed_commit_pages_for_nonvolatile_range(const VolatilePageRange&); size_t count_needed_commit_pages_for_nonvolatile_range(VolatilePageRange const&);
size_t mark_committed_pages_for_nonvolatile_range(const VolatilePageRange&, size_t); size_t mark_committed_pages_for_nonvolatile_range(VolatilePageRange const&, size_t);
bool is_nonvolatile(size_t page_index); bool is_nonvolatile(size_t page_index);
AnonymousVMObject& operator=(const AnonymousVMObject&) = delete; AnonymousVMObject& operator=(AnonymousVMObject const&) = delete;
AnonymousVMObject& operator=(AnonymousVMObject&&) = delete; AnonymousVMObject& operator=(AnonymousVMObject&&) = delete;
AnonymousVMObject(AnonymousVMObject&&) = delete; AnonymousVMObject(AnonymousVMObject&&) = delete;

View file

@ -27,7 +27,7 @@ ContiguousVMObject::ContiguousVMObject(size_t size, NonnullRefPtrVector<Physical
} }
} }
ContiguousVMObject::ContiguousVMObject(const ContiguousVMObject& other) ContiguousVMObject::ContiguousVMObject(ContiguousVMObject const& other)
: VMObject(other) : VMObject(other)
{ {
} }

View file

@ -19,12 +19,12 @@ public:
private: private:
explicit ContiguousVMObject(size_t, NonnullRefPtrVector<PhysicalPage>&); explicit ContiguousVMObject(size_t, NonnullRefPtrVector<PhysicalPage>&);
explicit ContiguousVMObject(const ContiguousVMObject&); explicit ContiguousVMObject(ContiguousVMObject const&);
virtual StringView class_name() const override { return "ContiguousVMObject"sv; } virtual StringView class_name() const override { return "ContiguousVMObject"sv; }
virtual RefPtr<VMObject> try_clone() override; virtual RefPtr<VMObject> try_clone() override;
ContiguousVMObject& operator=(const ContiguousVMObject&) = delete; ContiguousVMObject& operator=(ContiguousVMObject const&) = delete;
ContiguousVMObject& operator=(ContiguousVMObject&&) = delete; ContiguousVMObject& operator=(ContiguousVMObject&&) = delete;
ContiguousVMObject(ContiguousVMObject&&) = delete; ContiguousVMObject(ContiguousVMObject&&) = delete;

View file

@ -17,7 +17,7 @@ InodeVMObject::InodeVMObject(Inode& inode, size_t size)
{ {
} }
InodeVMObject::InodeVMObject(const InodeVMObject& other) InodeVMObject::InodeVMObject(InodeVMObject const& other)
: VMObject(other) : VMObject(other)
, m_inode(other.m_inode) , m_inode(other.m_inode)
, m_dirty_pages(page_count(), false) , m_dirty_pages(page_count(), false)

View file

@ -17,7 +17,7 @@ public:
virtual ~InodeVMObject() override; virtual ~InodeVMObject() override;
Inode& inode() { return *m_inode; } Inode& inode() { return *m_inode; }
const Inode& inode() const { return *m_inode; } Inode const& inode() const { return *m_inode; }
size_t amount_dirty() const; size_t amount_dirty() const;
size_t amount_clean() const; size_t amount_clean() const;
@ -29,9 +29,9 @@ public:
protected: protected:
explicit InodeVMObject(Inode&, size_t); explicit InodeVMObject(Inode&, size_t);
explicit InodeVMObject(const InodeVMObject&); explicit InodeVMObject(InodeVMObject const&);
InodeVMObject& operator=(const InodeVMObject&) = delete; InodeVMObject& operator=(InodeVMObject const&) = delete;
InodeVMObject& operator=(InodeVMObject&&) = delete; InodeVMObject& operator=(InodeVMObject&&) = delete;
InodeVMObject(InodeVMObject&&) = delete; InodeVMObject(InodeVMObject&&) = delete;

View file

@ -24,7 +24,7 @@ PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size)
{ {
} }
PrivateInodeVMObject::PrivateInodeVMObject(const PrivateInodeVMObject& other) PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other)
: InodeVMObject(other) : InodeVMObject(other)
{ {
} }

View file

@ -25,11 +25,11 @@ private:
virtual bool is_private_inode() const override { return true; } virtual bool is_private_inode() const override { return true; }
explicit PrivateInodeVMObject(Inode&, size_t); explicit PrivateInodeVMObject(Inode&, size_t);
explicit PrivateInodeVMObject(const PrivateInodeVMObject&); explicit PrivateInodeVMObject(PrivateInodeVMObject const&);
virtual StringView class_name() const override { return "PrivateInodeVMObject"sv; } virtual StringView class_name() const override { return "PrivateInodeVMObject"sv; }
PrivateInodeVMObject& operator=(const PrivateInodeVMObject&) = delete; PrivateInodeVMObject& operator=(PrivateInodeVMObject const&) = delete;
}; };
} }

View file

@ -31,7 +31,7 @@ SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
{ {
} }
SharedInodeVMObject::SharedInodeVMObject(const SharedInodeVMObject& other) SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other)
: InodeVMObject(other) : InodeVMObject(other)
{ {
} }

View file

@ -23,11 +23,11 @@ private:
virtual bool is_shared_inode() const override { return true; } virtual bool is_shared_inode() const override { return true; }
explicit SharedInodeVMObject(Inode&, size_t); explicit SharedInodeVMObject(Inode&, size_t);
explicit SharedInodeVMObject(const SharedInodeVMObject&); explicit SharedInodeVMObject(SharedInodeVMObject const&);
virtual StringView class_name() const override { return "SharedInodeVMObject"sv; } virtual StringView class_name() const override { return "SharedInodeVMObject"sv; }
SharedInodeVMObject& operator=(const SharedInodeVMObject&) = delete; SharedInodeVMObject& operator=(SharedInodeVMObject const&) = delete;
}; };
} }

View file

@ -9,7 +9,7 @@
namespace Kernel { namespace Kernel {
VMObject::VMObject(const VMObject& other) VMObject::VMObject(VMObject const& other)
: m_physical_pages(other.m_physical_pages) : m_physical_pages(other.m_physical_pages)
{ {
MM.register_vmobject(*this); MM.register_vmobject(*this);

View file

@ -63,7 +63,7 @@ public:
protected: protected:
explicit VMObject(size_t); explicit VMObject(size_t);
explicit VMObject(const VMObject&); explicit VMObject(VMObject const&);
template<typename Callback> template<typename Callback>
void for_each_region(Callback); void for_each_region(Callback);
@ -75,7 +75,7 @@ protected:
mutable SpinLock<u8> m_lock; mutable SpinLock<u8> m_lock;
private: private:
VMObject& operator=(const VMObject&) = delete; VMObject& operator=(VMObject const&) = delete;
VMObject& operator=(VMObject&&) = delete; VMObject& operator=(VMObject&&) = delete;
VMObject(VMObject&&) = delete; VMObject(VMObject&&) = delete;