summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authordegasus <wickmarkus@web.de>2017-01-11 20:24:13 +0100
committerdegasus <wickmarkus@web.de>2017-01-12 20:23:14 +0100
commit7e850361fbe4463dbfa433f09315ebfc5f6405bb (patch)
tree95c9b8064c572616bf5c4639bb2e1438999a838f /Source/Core
parentca026b58ab666ecc4fe814c1370fc0a1032f9337 (diff)
JitCache: Add a helper function to iterate over all blocks.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/JitCache.cpp6
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/JitCache.h2
-rw-r--r--Source/Core/Core/PowerPC/JitInterface.cpp17
-rw-r--r--Source/Core/Core/PowerPC/Profiler.h5
4 files changed, 17 insertions, 13 deletions
diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp
index ad15d0f449..1f825fa9ec 100644
--- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp
+++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp
@@ -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];
diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.h b/Source/Core/Core/PowerPC/JitCommon/JitCache.h
index 8c4bc04e2e..781fb596f4 100644
--- a/Source/Core/Core/PowerPC/JitCommon/JitCache.h
+++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.h
@@ -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);
diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp
index 790a377dc1..a342f7a6d7 100644
--- a/Source/Core/Core/PowerPC/JitInterface.cpp
+++ b/Source/Core/Core/PowerPC/JitInterface.cpp
@@ -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)
diff --git a/Source/Core/Core/PowerPC/Profiler.h b/Source/Core/Core/PowerPC/Profiler.h
index 4c11af58ed..6146bee4d1 100644
--- a/Source/Core/Core/PowerPC/Profiler.h
+++ b/Source/Core/Core/PowerPC/Profiler.h
@@ -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;