JITs: Add GetMemoryStats Function
Using the updated rangeset library
This commit is contained in:
parent
46f8fe0eaf
commit
a0987829e5
|
@ -408,6 +408,11 @@ void CachedInterpreter::EraseSingleBlock(const JitBlock& block)
|
||||||
FreeRanges();
|
FreeRanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<JitBase::MemoryStats> CachedInterpreter::GetMemoryStats() const
|
||||||
|
{
|
||||||
|
return {{"free", m_free_ranges.get_stats()}};
|
||||||
|
}
|
||||||
|
|
||||||
void CachedInterpreter::ClearCache()
|
void CachedInterpreter::ClearCache()
|
||||||
{
|
{
|
||||||
m_block_cache.Clear();
|
m_block_cache.Clear();
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
bool DoJit(u32 address, JitBlock* b, u32 nextPC);
|
bool DoJit(u32 address, JitBlock* b, u32 nextPC);
|
||||||
|
|
||||||
void EraseSingleBlock(const JitBlock& block) override;
|
void EraseSingleBlock(const JitBlock& block) override;
|
||||||
|
std::vector<MemoryStats> GetMemoryStats() const override;
|
||||||
|
|
||||||
static std::size_t Disassemble(const JitBlock& block, std::ostream& stream);
|
static std::size_t Disassemble(const JitBlock& block, std::ostream& stream);
|
||||||
|
|
||||||
|
|
|
@ -1208,6 +1208,11 @@ void Jit64::EraseSingleBlock(const JitBlock& block)
|
||||||
FreeRanges();
|
FreeRanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<JitBase::MemoryStats> Jit64::GetMemoryStats() const
|
||||||
|
{
|
||||||
|
return {{"near", m_free_ranges_near.get_stats()}, {"far", m_free_ranges_far.get_stats()}};
|
||||||
|
}
|
||||||
|
|
||||||
BitSet8 Jit64::ComputeStaticGQRs(const PPCAnalyst::CodeBlock& cb) const
|
BitSet8 Jit64::ComputeStaticGQRs(const PPCAnalyst::CodeBlock& cb) const
|
||||||
{
|
{
|
||||||
return cb.m_gqr_used & ~cb.m_gqr_modified;
|
return cb.m_gqr_used & ~cb.m_gqr_modified;
|
||||||
|
|
|
@ -66,6 +66,7 @@ public:
|
||||||
bool DoJit(u32 em_address, JitBlock* b, u32 nextPC);
|
bool DoJit(u32 em_address, JitBlock* b, u32 nextPC);
|
||||||
|
|
||||||
void EraseSingleBlock(const JitBlock& block) override;
|
void EraseSingleBlock(const JitBlock& block) override;
|
||||||
|
std::vector<MemoryStats> GetMemoryStats() const override;
|
||||||
|
|
||||||
// Finds a free memory region and sets the near and far code emitters to point at that region.
|
// Finds a free memory region and sets the near and far code emitters to point at that region.
|
||||||
// Returns false if no free memory region can be found for either of the two.
|
// Returns false if no free memory region can be found for either of the two.
|
||||||
|
|
|
@ -1040,6 +1040,14 @@ void JitArm64::EraseSingleBlock(const JitBlock& block)
|
||||||
FreeRanges();
|
FreeRanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<JitBase::MemoryStats> JitArm64::GetMemoryStats() const
|
||||||
|
{
|
||||||
|
return {{"near_0", m_free_ranges_near_0.get_stats()},
|
||||||
|
{"near_1", m_free_ranges_near_1.get_stats()},
|
||||||
|
{"far_0", m_free_ranges_far_0.get_stats()},
|
||||||
|
{"far_1", m_free_ranges_far_1.get_stats()}};
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<size_t> JitArm64::SetEmitterStateToFreeCodeRegion()
|
std::optional<size_t> JitArm64::SetEmitterStateToFreeCodeRegion()
|
||||||
{
|
{
|
||||||
// Find some large free memory blocks and set code emitters to point at them. If we can't find
|
// Find some large free memory blocks and set code emitters to point at them. If we can't find
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void Jit(u32 em_address, bool clear_cache_and_retry_on_failure);
|
void Jit(u32 em_address, bool clear_cache_and_retry_on_failure);
|
||||||
|
|
||||||
void EraseSingleBlock(const JitBlock& block) override;
|
void EraseSingleBlock(const JitBlock& block) override;
|
||||||
|
std::vector<MemoryStats> GetMemoryStats() const override;
|
||||||
|
|
||||||
const char* GetName() const override { return "JITARM64"; }
|
const char* GetName() const override { return "JITARM64"; }
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string_view>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/BitSet.h"
|
#include "Common/BitSet.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -196,6 +198,10 @@ public:
|
||||||
|
|
||||||
virtual void EraseSingleBlock(const JitBlock& block) = 0;
|
virtual void EraseSingleBlock(const JitBlock& block) = 0;
|
||||||
|
|
||||||
|
// Memory region name, free size, and fragmentation ratio
|
||||||
|
using MemoryStats = std::pair<std::string_view, std::pair<std::size_t, double>>;
|
||||||
|
virtual std::vector<MemoryStats> GetMemoryStats() const = 0;
|
||||||
|
|
||||||
virtual const CommonAsmRoutinesBase* GetAsmRoutines() = 0;
|
virtual const CommonAsmRoutinesBase* GetAsmRoutines() = 0;
|
||||||
|
|
||||||
virtual bool HandleFault(uintptr_t access_address, SContext* ctx) = 0;
|
virtual bool HandleFault(uintptr_t access_address, SContext* ctx) = 0;
|
||||||
|
|
|
@ -269,6 +269,13 @@ void JitInterface::EraseSingleBlock(const JitBlock& block)
|
||||||
m_jit->EraseSingleBlock(block);
|
m_jit->EraseSingleBlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<JitBase::MemoryStats> JitInterface::GetMemoryStats() const
|
||||||
|
{
|
||||||
|
if (m_jit)
|
||||||
|
return m_jit->GetMemoryStats();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void JitInterface::InvalidateICache(u32 address, u32 size, bool forced)
|
void JitInterface::InvalidateICache(u32 address, u32 size, bool forced)
|
||||||
{
|
{
|
||||||
if (m_jit)
|
if (m_jit)
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <utility>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Core/MachineContext.h"
|
#include "Core/MachineContext.h"
|
||||||
|
@ -78,6 +81,10 @@ public:
|
||||||
// outside of the Core *must* use this, consider reworking the logic in JITWidget.
|
// outside of the Core *must* use this, consider reworking the logic in JITWidget.
|
||||||
void EraseSingleBlock(const JitBlock& block);
|
void EraseSingleBlock(const JitBlock& block);
|
||||||
|
|
||||||
|
// Memory region name, free size, and fragmentation ratio
|
||||||
|
using MemoryStats = std::pair<std::string_view, std::pair<std::size_t, double>>;
|
||||||
|
std::vector<MemoryStats> GetMemoryStats() const;
|
||||||
|
|
||||||
// If "forced" is true, a recompile is being requested on code that hasn't been modified.
|
// If "forced" is true, a recompile is being requested on code that hasn't been modified.
|
||||||
void InvalidateICache(u32 address, u32 size, bool forced);
|
void InvalidateICache(u32 address, u32 size, bool forced);
|
||||||
void InvalidateICacheLine(u32 address);
|
void InvalidateICacheLine(u32 address);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
JitBaseBlockCache* GetBlockCache() override { return nullptr; }
|
JitBaseBlockCache* GetBlockCache() override { return nullptr; }
|
||||||
void Jit(u32 em_address) override {}
|
void Jit(u32 em_address) override {}
|
||||||
void EraseSingleBlock(const JitBlock&) override {}
|
void EraseSingleBlock(const JitBlock&) override {}
|
||||||
|
std::vector<MemoryStats> GetMemoryStats() const override { return {}; }
|
||||||
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
|
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
|
||||||
virtual bool HandleFault(uintptr_t access_address, SContext* ctx) override
|
virtual bool HandleFault(uintptr_t access_address, SContext* ctx) override
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue