kern: refactor to use m_ for member variables
This commit is contained in:
@@ -61,50 +61,50 @@ namespace ams::kern {
|
||||
return (util::AlignUp((region_size / PageSize), BITSIZEOF(u64)) / BITSIZEOF(u64)) * sizeof(u64);
|
||||
}
|
||||
private:
|
||||
KPageHeap heap;
|
||||
RefCount *page_reference_counts;
|
||||
KVirtualAddress management_region;
|
||||
Pool pool;
|
||||
Impl *next;
|
||||
Impl *prev;
|
||||
KPageHeap m_heap;
|
||||
RefCount *m_page_reference_counts;
|
||||
KVirtualAddress m_management_region;
|
||||
Pool m_pool;
|
||||
Impl *m_next;
|
||||
Impl *m_prev;
|
||||
public:
|
||||
Impl() : heap(), page_reference_counts(), management_region(), pool(), next(), prev() { /* ... */ }
|
||||
Impl() : m_heap(), m_page_reference_counts(), m_management_region(), m_pool(), m_next(), m_prev() { /* ... */ }
|
||||
|
||||
size_t Initialize(uintptr_t address, size_t size, KVirtualAddress management, KVirtualAddress management_end, Pool p);
|
||||
|
||||
KVirtualAddress AllocateBlock(s32 index, bool random) { return this->heap.AllocateBlock(index, random); }
|
||||
void Free(KVirtualAddress addr, size_t num_pages) { this->heap.Free(addr, num_pages); }
|
||||
KVirtualAddress AllocateBlock(s32 index, bool random) { return m_heap.AllocateBlock(index, random); }
|
||||
void Free(KVirtualAddress addr, size_t num_pages) { m_heap.Free(addr, num_pages); }
|
||||
|
||||
void UpdateUsedHeapSize() { this->heap.UpdateUsedSize(); }
|
||||
void UpdateUsedHeapSize() { m_heap.UpdateUsedSize(); }
|
||||
|
||||
void InitializeOptimizedMemory() { std::memset(GetVoidPointer(this->management_region), 0, CalculateOptimizedProcessOverheadSize(this->heap.GetSize())); }
|
||||
void InitializeOptimizedMemory() { std::memset(GetVoidPointer(m_management_region), 0, CalculateOptimizedProcessOverheadSize(m_heap.GetSize())); }
|
||||
|
||||
void TrackUnoptimizedAllocation(KVirtualAddress block, size_t num_pages);
|
||||
void TrackOptimizedAllocation(KVirtualAddress block, size_t num_pages);
|
||||
|
||||
bool ProcessOptimizedAllocation(KVirtualAddress block, size_t num_pages, u8 fill_pattern);
|
||||
|
||||
constexpr Pool GetPool() const { return this->pool; }
|
||||
constexpr size_t GetSize() const { return this->heap.GetSize(); }
|
||||
constexpr KVirtualAddress GetEndAddress() const { return this->heap.GetEndAddress(); }
|
||||
constexpr Pool GetPool() const { return m_pool; }
|
||||
constexpr size_t GetSize() const { return m_heap.GetSize(); }
|
||||
constexpr KVirtualAddress GetEndAddress() const { return m_heap.GetEndAddress(); }
|
||||
|
||||
size_t GetFreeSize() const { return this->heap.GetFreeSize(); }
|
||||
size_t GetFreeSize() const { return m_heap.GetFreeSize(); }
|
||||
|
||||
void DumpFreeList() const { return this->heap.DumpFreeList(); }
|
||||
void DumpFreeList() const { return m_heap.DumpFreeList(); }
|
||||
|
||||
constexpr size_t GetPageOffset(KVirtualAddress address) const { return this->heap.GetPageOffset(address); }
|
||||
constexpr size_t GetPageOffsetToEnd(KVirtualAddress address) const { return this->heap.GetPageOffsetToEnd(address); }
|
||||
constexpr size_t GetPageOffset(KVirtualAddress address) const { return m_heap.GetPageOffset(address); }
|
||||
constexpr size_t GetPageOffsetToEnd(KVirtualAddress address) const { return m_heap.GetPageOffsetToEnd(address); }
|
||||
|
||||
constexpr void SetNext(Impl *n) { this->next = n; }
|
||||
constexpr void SetPrev(Impl *n) { this->prev = n; }
|
||||
constexpr Impl *GetNext() const { return this->next; }
|
||||
constexpr Impl *GetPrev() const { return this->prev; }
|
||||
constexpr void SetNext(Impl *n) { m_next = n; }
|
||||
constexpr void SetPrev(Impl *n) { m_prev = n; }
|
||||
constexpr Impl *GetNext() const { return m_next; }
|
||||
constexpr Impl *GetPrev() const { return m_prev; }
|
||||
|
||||
void OpenFirst(KVirtualAddress address, size_t num_pages) {
|
||||
size_t index = this->GetPageOffset(address);
|
||||
const size_t end = index + num_pages;
|
||||
while (index < end) {
|
||||
const RefCount ref_count = (++this->page_reference_counts[index]);
|
||||
const RefCount ref_count = (++m_page_reference_counts[index]);
|
||||
MESOSPHERE_ABORT_UNLESS(ref_count == 1);
|
||||
|
||||
index++;
|
||||
@@ -115,7 +115,7 @@ namespace ams::kern {
|
||||
size_t index = this->GetPageOffset(address);
|
||||
const size_t end = index + num_pages;
|
||||
while (index < end) {
|
||||
const RefCount ref_count = (++this->page_reference_counts[index]);
|
||||
const RefCount ref_count = (++m_page_reference_counts[index]);
|
||||
MESOSPHERE_ABORT_UNLESS(ref_count > 1);
|
||||
|
||||
index++;
|
||||
@@ -129,8 +129,8 @@ namespace ams::kern {
|
||||
size_t free_start = 0;
|
||||
size_t free_count = 0;
|
||||
while (index < end) {
|
||||
MESOSPHERE_ABORT_UNLESS(this->page_reference_counts[index] > 0);
|
||||
const RefCount ref_count = (--this->page_reference_counts[index]);
|
||||
MESOSPHERE_ABORT_UNLESS(m_page_reference_counts[index] > 0);
|
||||
const RefCount ref_count = (--m_page_reference_counts[index]);
|
||||
|
||||
/* Keep track of how many zero refcounts we see in a row, to minimize calls to free. */
|
||||
if (ref_count == 0) {
|
||||
@@ -142,7 +142,7 @@ namespace ams::kern {
|
||||
}
|
||||
} else {
|
||||
if (free_count > 0) {
|
||||
this->Free(this->heap.GetAddress() + free_start * PageSize, free_count);
|
||||
this->Free(m_heap.GetAddress() + free_start * PageSize, free_count);
|
||||
free_count = 0;
|
||||
}
|
||||
}
|
||||
@@ -151,25 +151,25 @@ namespace ams::kern {
|
||||
}
|
||||
|
||||
if (free_count > 0) {
|
||||
this->Free(this->heap.GetAddress() + free_start * PageSize, free_count);
|
||||
this->Free(m_heap.GetAddress() + free_start * PageSize, free_count);
|
||||
}
|
||||
}
|
||||
};
|
||||
private:
|
||||
KLightLock pool_locks[Pool_Count];
|
||||
Impl *pool_managers_head[Pool_Count];
|
||||
Impl *pool_managers_tail[Pool_Count];
|
||||
Impl managers[MaxManagerCount];
|
||||
size_t num_managers;
|
||||
u64 optimized_process_ids[Pool_Count];
|
||||
bool has_optimized_process[Pool_Count];
|
||||
KLightLock m_pool_locks[Pool_Count];
|
||||
Impl *m_pool_managers_head[Pool_Count];
|
||||
Impl *m_pool_managers_tail[Pool_Count];
|
||||
Impl m_managers[MaxManagerCount];
|
||||
size_t m_num_managers;
|
||||
u64 m_optimized_process_ids[Pool_Count];
|
||||
bool m_has_optimized_process[Pool_Count];
|
||||
private:
|
||||
Impl &GetManager(KVirtualAddress address) {
|
||||
return this->managers[KMemoryLayout::GetVirtualLinearRegion(address).GetAttributes()];
|
||||
return m_managers[KMemoryLayout::GetVirtualLinearRegion(address).GetAttributes()];
|
||||
}
|
||||
|
||||
constexpr Impl *GetFirstManager(Pool pool, Direction dir) {
|
||||
return dir == Direction_FromBack ? this->pool_managers_tail[pool] : this->pool_managers_head[pool];
|
||||
return dir == Direction_FromBack ? m_pool_managers_tail[pool] : m_pool_managers_head[pool];
|
||||
}
|
||||
|
||||
constexpr Impl *GetNextManager(Impl *cur, Direction dir) {
|
||||
@@ -183,7 +183,7 @@ namespace ams::kern {
|
||||
Result AllocatePageGroupImpl(KPageGroup *out, size_t num_pages, Pool pool, Direction dir, bool unoptimized, bool random);
|
||||
public:
|
||||
KMemoryManager()
|
||||
: pool_locks(), pool_managers_head(), pool_managers_tail(), managers(), num_managers(), optimized_process_ids(), has_optimized_process()
|
||||
: m_pool_locks(), m_pool_managers_head(), m_pool_managers_tail(), m_managers(), m_num_managers(), m_optimized_process_ids(), m_has_optimized_process()
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@@ -204,7 +204,7 @@ namespace ams::kern {
|
||||
const size_t cur_pages = std::min(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
|
||||
{
|
||||
KScopedLightLock lk(this->pool_locks[manager.GetPool()]);
|
||||
KScopedLightLock lk(m_pool_locks[manager.GetPool()]);
|
||||
manager.Open(address, cur_pages);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace ams::kern {
|
||||
const size_t cur_pages = std::min(num_pages, manager.GetPageOffsetToEnd(address));
|
||||
|
||||
{
|
||||
KScopedLightLock lk(this->pool_locks[manager.GetPool()]);
|
||||
KScopedLightLock lk(m_pool_locks[manager.GetPool()]);
|
||||
manager.Close(address, cur_pages);
|
||||
}
|
||||
|
||||
@@ -231,8 +231,8 @@ namespace ams::kern {
|
||||
|
||||
size_t GetSize() {
|
||||
size_t total = 0;
|
||||
for (size_t i = 0; i < this->num_managers; i++) {
|
||||
total += this->managers[i].GetSize();
|
||||
for (size_t i = 0; i < m_num_managers; i++) {
|
||||
total += m_managers[i].GetSize();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
@@ -248,15 +248,15 @@ namespace ams::kern {
|
||||
|
||||
size_t GetFreeSize() {
|
||||
size_t total = 0;
|
||||
for (size_t i = 0; i < this->num_managers; i++) {
|
||||
KScopedLightLock lk(this->pool_locks[this->managers[i].GetPool()]);
|
||||
total += this->managers[i].GetFreeSize();
|
||||
for (size_t i = 0; i < m_num_managers; i++) {
|
||||
KScopedLightLock lk(m_pool_locks[m_managers[i].GetPool()]);
|
||||
total += m_managers[i].GetFreeSize();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
size_t GetFreeSize(Pool pool) {
|
||||
KScopedLightLock lk(this->pool_locks[pool]);
|
||||
KScopedLightLock lk(m_pool_locks[pool]);
|
||||
|
||||
constexpr Direction GetSizeDirection = Direction_FromFront;
|
||||
size_t total = 0;
|
||||
@@ -267,7 +267,7 @@ namespace ams::kern {
|
||||
}
|
||||
|
||||
void DumpFreeList(Pool pool) {
|
||||
KScopedLightLock lk(this->pool_locks[pool]);
|
||||
KScopedLightLock lk(m_pool_locks[pool]);
|
||||
|
||||
constexpr Direction DumpDirection = Direction_FromFront;
|
||||
for (auto *manager = this->GetFirstManager(pool, DumpDirection); manager != nullptr; manager = this->GetNextManager(manager, DumpDirection)) {
|
||||
|
||||
Reference in New Issue
Block a user