|
@@ -39,29 +39,29 @@ class PhysicalPage {
|
|
friend class PageDirectory;
|
|
friend class PageDirectory;
|
|
friend class VMObject;
|
|
friend class VMObject;
|
|
|
|
|
|
- MAKE_SLAB_ALLOCATED(PhysicalPage);
|
|
|
|
- AK_MAKE_NONMOVABLE(PhysicalPage);
|
|
|
|
-
|
|
|
|
|
|
+ MAKE_SLAB_ALLOCATED(PhysicalPage)
|
|
public:
|
|
public:
|
|
PhysicalAddress paddr() const { return m_paddr; }
|
|
PhysicalAddress paddr() const { return m_paddr; }
|
|
|
|
|
|
void ref()
|
|
void ref()
|
|
{
|
|
{
|
|
- m_ref_count.fetch_add(1, AK::memory_order_acq_rel);
|
|
|
|
|
|
+ ASSERT(m_ref_count);
|
|
|
|
+ ++m_ref_count;
|
|
}
|
|
}
|
|
|
|
|
|
void unref()
|
|
void unref()
|
|
{
|
|
{
|
|
- if (m_ref_count.fetch_sub(1, AK::memory_order_acq_rel) == 1) {
|
|
|
|
|
|
+ ASSERT(m_ref_count);
|
|
|
|
+ if (!--m_ref_count) {
|
|
if (m_may_return_to_freelist)
|
|
if (m_may_return_to_freelist)
|
|
- return_to_freelist();
|
|
|
|
|
|
+ move(*this).return_to_freelist();
|
|
delete this;
|
|
delete this;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
|
|
static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
|
|
|
|
|
|
- u32 ref_count() const { return m_ref_count.load(AK::memory_order_consume); }
|
|
|
|
|
|
+ u32 ref_count() const { return m_ref_count; }
|
|
|
|
|
|
bool is_shared_zero_page() const;
|
|
bool is_shared_zero_page() const;
|
|
|
|
|
|
@@ -69,9 +69,9 @@ private:
|
|
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
|
|
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
|
|
~PhysicalPage() {}
|
|
~PhysicalPage() {}
|
|
|
|
|
|
- void return_to_freelist() const;
|
|
|
|
|
|
+ void return_to_freelist() &&;
|
|
|
|
|
|
- Atomic<u32> m_ref_count { 1 };
|
|
|
|
|
|
+ u32 m_ref_count { 1 };
|
|
bool m_may_return_to_freelist { true };
|
|
bool m_may_return_to_freelist { true };
|
|
bool m_supervisor { false };
|
|
bool m_supervisor { false };
|
|
PhysicalAddress m_paddr;
|
|
PhysicalAddress m_paddr;
|