mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
JitCache: Add a helper function to iterate over all blocks.
This commit is contained in:
parent
ca026b58ab
commit
7e850361fb
@ -119,6 +119,12 @@ int* JitBaseBlockCache::GetICache()
|
||||
return iCache.data();
|
||||
}
|
||||
|
||||
void JitBaseBlockCache::RunOnBlocks(std::function<void(const JitBlock&)> f)
|
||||
{
|
||||
for (int i = 0; i < num_blocks; i++)
|
||||
f(blocks[i]);
|
||||
}
|
||||
|
||||
JitBlock* JitBaseBlockCache::AllocateBlock(u32 em_address)
|
||||
{
|
||||
JitBlock& b = blocks[num_blocks];
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@ -130,6 +131,7 @@ public:
|
||||
JitBlock* GetBlocks();
|
||||
int GetNumBlocks() const;
|
||||
int* GetICache();
|
||||
void RunOnBlocks(std::function<void(const JitBlock&)> f);
|
||||
|
||||
JitBlock* AllocateBlock(u32 em_address);
|
||||
void FinalizeBlock(JitBlock& b, bool block_link, const u8* code_ptr);
|
||||
|
@ -134,26 +134,23 @@ void GetProfileResults(ProfileStats* prof_stats)
|
||||
prof_stats->cost_sum = 0;
|
||||
prof_stats->timecost_sum = 0;
|
||||
prof_stats->block_stats.clear();
|
||||
prof_stats->block_stats.reserve(g_jit->GetBlockCache()->GetNumBlocks());
|
||||
|
||||
Core::EState old_state = Core::GetState();
|
||||
if (old_state == Core::CORE_RUN)
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*)&prof_stats->countsPerSec);
|
||||
for (int i = 0; i < g_jit->GetBlockCache()->GetNumBlocks(); i++)
|
||||
{
|
||||
const JitBlock* block = g_jit->GetBlockCache()->GetBlock(i);
|
||||
g_jit->GetBlockCache()->RunOnBlocks([&prof_stats](const JitBlock& block) {
|
||||
// Rough heuristic. Mem instructions should cost more.
|
||||
u64 cost = block->originalSize * (block->runCount / 4);
|
||||
u64 timecost = block->ticCounter;
|
||||
u64 cost = block.originalSize * (block.runCount / 4);
|
||||
u64 timecost = block.ticCounter;
|
||||
// Todo: tweak.
|
||||
if (block->runCount >= 1)
|
||||
prof_stats->block_stats.emplace_back(i, block->effectiveAddress, cost, timecost,
|
||||
block->runCount, block->codeSize);
|
||||
if (block.runCount >= 1)
|
||||
prof_stats->block_stats.emplace_back(block.effectiveAddress, cost, timecost, block.runCount,
|
||||
block.codeSize);
|
||||
prof_stats->cost_sum += cost;
|
||||
prof_stats->timecost_sum += timecost;
|
||||
}
|
||||
});
|
||||
|
||||
sort(prof_stats->block_stats.begin(), prof_stats->block_stats.end());
|
||||
if (old_state == Core::CORE_RUN)
|
||||
|
@ -43,11 +43,10 @@
|
||||
|
||||
struct BlockStat
|
||||
{
|
||||
BlockStat(int bn, u32 _addr, u64 c, u64 ticks, u64 run, u32 size)
|
||||
: blockNum(bn), addr(_addr), cost(c), tick_counter(ticks), run_count(run), block_size(size)
|
||||
BlockStat(u32 _addr, u64 c, u64 ticks, u64 run, u32 size)
|
||||
: addr(_addr), cost(c), tick_counter(ticks), run_count(run), block_size(size)
|
||||
{
|
||||
}
|
||||
int blockNum;
|
||||
u32 addr;
|
||||
u64 cost;
|
||||
u64 tick_counter;
|
||||
|
Loading…
Reference in New Issue
Block a user