diff --git a/Core/MIPS/IR/IRJit.cpp b/Core/MIPS/IR/IRJit.cpp index 07c7a54162..6815c941ed 100644 --- a/Core/MIPS/IR/IRJit.cpp +++ b/Core/MIPS/IR/IRJit.cpp @@ -465,7 +465,6 @@ void IRBlockCache::ComputeStats(BlockCacheStats &bcStats) const { bcStats.maxBloatBlock = origAddr; } totalBloat += bloat; - bcStats.bloatMap[bloat] = origAddr; } bcStats.numBlocks = (int)blocks_.size(); bcStats.minBloat = minBloat; diff --git a/Core/MIPS/IR/IRNativeCommon.cpp b/Core/MIPS/IR/IRNativeCommon.cpp index e0a0b4d099..c3253230bc 100644 --- a/Core/MIPS/IR/IRNativeCommon.cpp +++ b/Core/MIPS/IR/IRNativeCommon.cpp @@ -801,7 +801,6 @@ void IRNativeBlockCacheDebugInterface::ComputeStats(BlockCacheStats &bcStats) co bcStats.maxBloatBlock = origAddr; } totalBloat += bloat; - bcStats.bloatMap[(float)bloat] = origAddr; } bcStats.numBlocks = numBlocks; bcStats.minBloat = (float)minBloat; diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index 120207eb60..cf1838951b 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -681,7 +681,6 @@ void JitBlockCache::ComputeStats(BlockCacheStats &bcStats) const { bcStats.maxBloatBlock = b->originalAddress; } totalBloat += bloat; - bcStats.bloatMap[(float)bloat] = b->originalAddress; } bcStats.numBlocks = num_blocks_; bcStats.minBloat = (float)minBloat; @@ -710,6 +709,5 @@ JitBlockDebugInfo JitBlockCache::GetBlockDebugInfo(int blockNum) const { #elif PPSSPP_ARCH(RISCV64) debugInfo.targetDisasm = DisassembleRV64(block->normalEntry, block->codeSize); #endif - return debugInfo; } diff --git a/Core/MIPS/JitCommon/JitBlockCache.h b/Core/MIPS/JitCommon/JitBlockCache.h index cfd363b69e..16457b0b06 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.h +++ b/Core/MIPS/JitCommon/JitBlockCache.h @@ -42,7 +42,6 @@ struct BlockCacheStats { u32 minBloatBlock; float maxBloat; u32 maxBloatBlock; - std::map bloatMap; }; enum class DestroyType { diff --git a/UI/JitCompareScreen.cpp b/UI/JitCompareScreen.cpp index 540fe47849..f14ddfa908 100644 --- a/UI/JitCompareScreen.cpp +++ b/UI/JitCompareScreen.cpp @@ -21,14 +21,22 @@ JitCompareScreen::JitCompareScreen() : UIDialogScreenWithBackground() { void JitCompareScreen::Flip() { using namespace UI; + // If we add more, let's convert to a for loop. switch (viewMode_) { case ViewMode::DISASM: comparisonView_->SetVisibility(V_VISIBLE); blockListView_->SetVisibility(V_GONE); + statsView_->SetVisibility(V_GONE); break; case ViewMode::BLOCK_LIST: comparisonView_->SetVisibility(V_GONE); blockListView_->SetVisibility(V_VISIBLE); + statsView_->SetVisibility(V_GONE); + break; + case ViewMode::STATS: + comparisonView_->SetVisibility(V_GONE); + blockListView_->SetVisibility(V_GONE); + statsView_->SetVisibility(V_VISIBLE); break; } } @@ -130,6 +138,13 @@ void JitCompareScreen::CreateViews() { ScrollView *blockScroll = blockListView_->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); blockListContainer_ = blockScroll->Add(new LinearLayout(ORIENT_VERTICAL)); + statsView_ = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); + statsView_->SetVisibility(V_GONE); + + LinearLayout *statsTopBar = statsView_->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + ScrollView *statsScroll = statsView_->Add(new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); + statsContainer_ = statsScroll->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); + // leftColumn->Add(new Choice(dev->T("By Address")))->OnClick.Handle(this, &JitCompareScreen::OnSelectBlock); leftColumn->Add(new Choice(dev->T("All")))->OnClick.Add([=](UI::EventParams &e) { listType_ = ListType::ALL_BLOCKS; @@ -295,9 +310,18 @@ void JitCompareScreen::UpdateDisasm() { int numMips = leftDisasm_->GetNumSubviews(); int numHost = rightDisasm_->GetNumSubviews(); - snprintf(temp, sizeof(temp), "%d to %d : %d%%", numMips, numHost, 100 * numHost / numMips); + double bloat = 100.0 * numHost / numMips; + if (blockCacheDebug->SupportsProfiling()) { + JitBlockProfileStats stats = blockCacheDebug->GetBlockProfileStats(blockNum); + int execs = (int)stats.executions; + double us = (double)stats.totalNanos / 1000000.0; + double percentage = 100.0 * (double)stats.totalNanos / (double)sumTotalNanos_; + snprintf(temp, sizeof(temp), "%d runs, %0.2f ms, %0.2f%%, bloat: %0.1f%%", execs, us, percentage, bloat); + } else { + snprintf(temp, sizeof(temp), "bloat: %0.1f%%", bloat); + } blockStats_->SetText(temp); - } else { + } else if (viewMode_ == ViewMode::BLOCK_LIST) { blockListContainer_->Clear(); bool profiling = blockCacheDebug->SupportsProfiling(); for (int i = 0; i < std::min(100, (int)blockList_.size()); i++) { @@ -309,7 +333,7 @@ void JitCompareScreen::UpdateDisasm() { int execs = (int)stats.executions; double us = (double)stats.totalNanos / 1000000.0; double percentage = 100.0 * (double)stats.totalNanos / (double)sumTotalNanos_; - snprintf(temp, sizeof(temp), "%08x: %d instrs (%d exec, %0.2f ms, %0.2f%%)", meta.addr, meta.sizeInBytes / 4, execs, us, percentage); + snprintf(temp, sizeof(temp), "%08x: %d instrs (%d runs, %0.2f ms, %0.2f%%)", meta.addr, meta.sizeInBytes / 4, execs, us, percentage); } else { snprintf(temp, sizeof(temp), "%08x: %d instrs", meta.addr, meta.sizeInBytes / 4); } @@ -317,6 +341,24 @@ void JitCompareScreen::UpdateDisasm() { Choice *blockChoice = blockListContainer_->Add(new Choice(temp, small)); blockChoice->OnClick.Handle(this, &JitCompareScreen::OnBlockClick); } + } else { // viewMode_ == ViewMode::STATS + statsContainer_->Clear(); + + BlockCacheStats bcStats; + blockCacheDebug->ComputeStats(bcStats); + + char stats[1024]; + snprintf(stats, sizeof(stats), + "Num blocks: %d\n" + "Average Bloat: %0.2f%%\n" + "Min Bloat: %0.2f%% (%08x)\n" + "Max Bloat: %0.2f%% (%08x)\n", + blockCacheDebug->GetNumBlocks(), + 100.0 * bcStats.avgBloat, + 100.0 * bcStats.minBloat, bcStats.minBloatBlock, + 100.0 * bcStats.maxBloat, bcStats.maxBloatBlock); + + statsContainer_->Add(new TextView(stats)); } } @@ -356,26 +398,8 @@ UI::EventReturn JitCompareScreen::OnShowStats(UI::EventParams &e) { return UI::EVENT_DONE; } - JitBlockCacheDebugInterface *blockCache = MIPSComp::jit->GetBlockCacheDebugInterface(); - if (!blockCache) - return UI::EVENT_DONE; - - BlockCacheStats bcStats; - blockCache->ComputeStats(bcStats); - NOTICE_LOG(JIT, "Num blocks: %i", bcStats.numBlocks); - NOTICE_LOG(JIT, "Average Bloat: %0.2f%%", 100 * bcStats.avgBloat); - NOTICE_LOG(JIT, "Min Bloat: %0.2f%% (%08x)", 100 * bcStats.minBloat, bcStats.minBloatBlock); - NOTICE_LOG(JIT, "Max Bloat: %0.2f%% (%08x)", 100 * bcStats.maxBloat, bcStats.maxBloatBlock); - - int ctr = 0, sz = (int)bcStats.bloatMap.size(); - for (auto iter : bcStats.bloatMap) { - if (ctr < 10 || ctr > sz - 10) { - NOTICE_LOG(JIT, "%08x: %f", iter.second, iter.first); - } else if (ctr == 10) { - NOTICE_LOG(JIT, "..."); - } - ctr++; - } + viewMode_ = ViewMode::STATS; + UpdateDisasm(); return UI::EVENT_DONE; } diff --git a/UI/JitCompareScreen.h b/UI/JitCompareScreen.h index b3af60d9ff..8a3828f1e4 100644 --- a/UI/JitCompareScreen.h +++ b/UI/JitCompareScreen.h @@ -17,9 +17,15 @@ private: void FillBlockList(); UI::LinearLayout *comparisonView_; + UI::LinearLayout *leftDisasm_; + UI::LinearLayout *rightDisasm_; + UI::LinearLayout *blockListView_; UI::LinearLayout *blockListContainer_; + UI::LinearLayout *statsView_; + UI::LinearLayout *statsContainer_; + UI::EventReturn OnSelectBlock(UI::EventParams &e); UI::EventReturn OnBlockAddress(UI::EventParams &e); UI::EventReturn OnAddressChange(UI::EventParams &e); @@ -30,6 +36,7 @@ private: enum class ViewMode { BLOCK_LIST, DISASM, + STATS, }; enum class ListType { ALL_BLOCKS, @@ -56,9 +63,6 @@ private: UI::TextView *blockName_; UI::TextEdit *blockAddr_; UI::TextView *blockStats_; - - UI::LinearLayout *leftDisasm_; - UI::LinearLayout *rightDisasm_; }; class AddressPromptScreen : public PopupScreen {