mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
IRJit block profiling basics
This commit is contained in:
1 parent
247a06e033
commit
ba1ced77c3
3 files changed
+35
-1
No files matched your search
@@ -40,6 +40,7 @@
|
||||
#include "Core/MIPS/IR/IRNativeCommon.h"
|
||||
#include "Core/MIPS/JitCommon/JitCommon.h"
|
||||
#include "Core/Reporting.h"
|
||||
#include "Common/TimeUtil.h"
|
||||
|
||||
namespace MIPSComp {
|
||||
|
||||
@@ -257,7 +258,17 @@ void IRJit::RunLoopUntil(u64 globalticks) {
|
||||
u32 opcode = inst & 0xFF000000;
|
||||
if (opcode == MIPS_EMUHACK_OPCODE) {
|
||||
IRBlock *block = blocks_.GetBlockUnchecked(inst & 0xFFFFFF);
|
||||
|
||||
#ifdef IR_PROFILING
|
||||
{
|
||||
TimeSpan span;
|
||||
mips->pc = IRInterpret(mips, block->GetInstructions());
|
||||
block->profileStats_.executions += 1;
|
||||
block->profileStats_.totalNanos += span.ElapsedNanos();
|
||||
}
|
||||
#else
|
||||
mips->pc = IRInterpret(mips, block->GetInstructions());
|
||||
#endif
|
||||
// Note: this will "jump to zero" on a badly constructed block missing exits.
|
||||
if (!Memory::IsValid4AlignedAddress(mips->pc)) {
|
||||
Core_ExecException(mips->pc, block->GetOriginalStart(), ExecExceptionType::JUMP);
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "stddef.h"
|
||||
#endif
|
||||
|
||||
// #define IR_PROFILING
|
||||
|
||||
namespace MIPSComp {
|
||||
|
||||
// TODO : Use arena allocators. For now let's just malloc.
|
||||
@@ -98,6 +100,10 @@ public:
|
||||
void Finalize(int number);
|
||||
void Destroy(int number);
|
||||
|
||||
#ifdef IR_PROFILING
|
||||
JitBlockProfileStats profileStats_{};
|
||||
#endif
|
||||
|
||||
private:
|
||||
u64 CalculateHash() const;
|
||||
|
||||
@@ -152,6 +158,14 @@ public:
|
||||
void ComputeStats(BlockCacheStats &bcStats) const override;
|
||||
int GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly = true) const override;
|
||||
|
||||
bool SupportsProfiling() const override {
|
||||
#ifdef IR_PROFILING
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
u32 AddressToPage(u32 addr) const;
|
||||
|
||||
|
||||
@@ -103,13 +103,22 @@ struct JitBlockDebugInfo {
|
||||
std::vector<std::string> targetDisasm;
|
||||
};
|
||||
|
||||
struct JitBlockProfileStats {
|
||||
int64_t executions;
|
||||
int64_t totalNanos;
|
||||
};
|
||||
|
||||
class JitBlockCacheDebugInterface {
|
||||
public:
|
||||
virtual int GetNumBlocks() const = 0;
|
||||
virtual int GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly = true) const = 0;
|
||||
virtual JitBlockDebugInfo GetBlockDebugInfo(int blockNum) const = 0;
|
||||
virtual JitBlockDebugInfo GetBlockDebugInfo(int blockNum) const = 0; // Expensive
|
||||
virtual JitBlockProfileStats GetBlockProfileStats(int blockNum) const { // Cheap
|
||||
return JitBlockProfileStats{};
|
||||
}
|
||||
virtual void ComputeStats(BlockCacheStats &bcStats) const = 0;
|
||||
virtual bool IsValidBlock(int blockNum) const = 0;
|
||||
virtual bool SupportsProfiling() const { return false; }
|
||||
|
||||
virtual ~JitBlockCacheDebugInterface() {}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user