diff --git a/Core/MIPS/IR/IRJit.h b/Core/MIPS/IR/IRJit.h index 171bebe3bf..744715836c 100644 --- a/Core/MIPS/IR/IRJit.h +++ b/Core/MIPS/IR/IRJit.h @@ -33,7 +33,7 @@ #include "stddef.h" #endif -#define IR_PROFILING +// #define IR_PROFILING namespace MIPSComp { @@ -163,6 +163,13 @@ public: } return meta; } + JitBlockProfileStats GetBlockProfileStats(int blockNum) const { // Cheap +#ifdef IR_PROFILING + return blocks_[blockNum].profileStats_; +#else + return JitBlockProfileStats{}; +#endif + } void ComputeStats(BlockCacheStats &bcStats) const override; int GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly = true) const override; diff --git a/Core/MIPS/IR/IRNativeCommon.cpp b/Core/MIPS/IR/IRNativeCommon.cpp index cf9d597823..e0a0b4d099 100644 --- a/Core/MIPS/IR/IRNativeCommon.cpp +++ b/Core/MIPS/IR/IRNativeCommon.cpp @@ -730,6 +730,10 @@ int IRNativeBlockCacheDebugInterface::GetBlockNumberFromStartAddress(u32 em_addr return irBlocks_.GetBlockNumberFromStartAddress(em_address, realBlocksOnly); } +JitBlockProfileStats IRNativeBlockCacheDebugInterface::GetBlockProfileStats(int blockNum) const { + return irBlocks_.GetBlockProfileStats(blockNum); +} + void IRNativeBlockCacheDebugInterface::GetBlockCodeRange(int blockNum, int *startOffset, int *size) const { int blockOffset = irBlocks_.GetBlock(blockNum)->GetTargetOffset(); int endOffset = backend_->GetNativeBlock(blockNum)->checkedOffset; diff --git a/Core/MIPS/IR/IRNativeCommon.h b/Core/MIPS/IR/IRNativeCommon.h index dd2f3878a4..a5ccea28f4 100644 --- a/Core/MIPS/IR/IRNativeCommon.h +++ b/Core/MIPS/IR/IRNativeCommon.h @@ -166,6 +166,7 @@ public: int GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly = true) const override; JitBlockDebugInfo GetBlockDebugInfo(int blockNum) const override; JitBlockMeta GetBlockMeta(int blockNum) const override; + JitBlockProfileStats GetBlockProfileStats(int blockNum) const override; void ComputeStats(BlockCacheStats &bcStats) const override; bool IsValidBlock(int blockNum) const override; diff --git a/Core/MIPS/JitCommon/JitBlockCache.h b/Core/MIPS/JitCommon/JitBlockCache.h index 793650af29..cfd363b69e 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.h +++ b/Core/MIPS/JitCommon/JitBlockCache.h @@ -120,9 +120,7 @@ public: virtual int GetBlockNumberFromStartAddress(u32 em_address, bool realBlocksOnly = true) const = 0; virtual JitBlockDebugInfo GetBlockDebugInfo(int blockNum) const = 0; // Expensive virtual JitBlockMeta GetBlockMeta(int blockNum) const = 0; - virtual JitBlockProfileStats GetBlockProfileStats(int blockNum) const { // Cheap - return JitBlockProfileStats{}; - } + virtual JitBlockProfileStats GetBlockProfileStats(int blockNum) const = 0; virtual void ComputeStats(BlockCacheStats &bcStats) const = 0; virtual bool IsValidBlock(int blockNum) const = 0; virtual bool SupportsProfiling() const { return false; } @@ -191,6 +189,9 @@ public: } return meta; } + JitBlockProfileStats GetBlockProfileStats(int blockNum) const override { + return JitBlockProfileStats{}; + } static int GetBlockExitSize(); diff --git a/UI/JitCompareScreen.cpp b/UI/JitCompareScreen.cpp index 245a205ed1..1d1630dd14 100644 --- a/UI/JitCompareScreen.cpp +++ b/UI/JitCompareScreen.cpp @@ -47,12 +47,14 @@ void JitCompareScreen::CreateViews() { return UI::EVENT_DONE; }); blockTopBar->Add(new Button("", ImageID("I_ARROW_LEFT")))->OnClick.Add([=](UI::EventParams &e) { - currentBlock_--; + if (currentBlock_ >= 1) + currentBlock_--; UpdateDisasm(); return UI::EVENT_DONE; }); blockTopBar->Add(new Button("", ImageID("I_ARROW_RIGHT")))->OnClick.Add([=](UI::EventParams &e) { - currentBlock_++; + if (currentBlock_ < blockList_.size() - 1) + currentBlock_++; UpdateDisasm(); return UI::EVENT_DONE; }); @@ -276,10 +278,11 @@ void JitCompareScreen::UpdateDisasm() { } else { blockListContainer_->Clear(); for (int i = 0; i < std::min(100, (int)blockList_.size()); i++) { - JitBlockMeta meta = blockCacheDebug->GetBlockMeta(blockList_[i]); + int blockNum = blockList_[i]; + JitBlockMeta meta = blockCacheDebug->GetBlockMeta(blockNum); char temp[512], small[512]; if (blockCacheDebug->SupportsProfiling()) { - JitBlockProfileStats stats = blockCacheDebug->GetBlockProfileStats(blockList_[i]); + JitBlockProfileStats stats = blockCacheDebug->GetBlockProfileStats(blockNum); int execs = (int)stats.executions; double us = (double)stats.totalNanos / 1000.0; snprintf(temp, sizeof(temp), "%08x: %d instrs (%d exec, %0.2f us)", meta.addr, meta.sizeInBytes / 4, execs, us);