From 75a38729239b1303bd2052c3e7695d1b464a8655 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 19 Jan 2013 19:07:11 -0800 Subject: [PATCH 1/2] Log missed jit ops for poor man profiling. --- Core/MIPS/x86/Jit.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index f0ac586be2..e372bd63f1 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include #include "../../Core.h" #include "../../CoreTiming.h" #include "../MIPS.h" @@ -45,6 +47,15 @@ static u64 saved_flags; #endif +const bool USE_JIT_MISSMAP = false; +static std::map notJitOps; + +template +std::pair flip_pair(const std::pair &p) +{ + return std::pair(p.second, p.first); +} + void JitBreakpoint() { Core_EnableStepping(true); @@ -52,6 +63,27 @@ void JitBreakpoint() if (CBreakPoints::IsTempBreakPoint(currentMIPS->pc)) CBreakPoints::RemoveBreakPoint(currentMIPS->pc); + + // There's probably a better place for this. + if (USE_JIT_MISSMAP) + { + std::map notJitSorted; + std::transform(notJitOps.begin(), notJitOps.end(), std::inserter(notJitSorted, notJitSorted.begin()), flip_pair); + + std::string message; + char temp[256]; + int remaining = 15; + for (auto it = notJitSorted.rbegin(), end = notJitSorted.rend(); it != end && --remaining >= 0; ++it) + { + snprintf(temp, 256, " (%d), ", it->first); + message += it->second + temp; + } + + if (message.size() > 2) + message.resize(message.size() - 2); + + NOTICE_LOG(JIT, "Top ops compiled to interpreter: %s", message.c_str()); + } } Jit::Jit(MIPSState *mips) : blocks(mips), mips_(mips) @@ -178,6 +210,9 @@ void Jit::Comp_RunBlock(u32 op) void Jit::Comp_Generic(u32 op) { + if (USE_JIT_MISSMAP) + notJitOps[MIPSGetName(op)]++; + FlushAll(); MIPSInterpretFunc func = MIPSGetInterpretFunc(op); if (func) From 385417effe30cdb56db1a623057d55457801147a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 19 Jan 2013 20:11:17 -0800 Subject: [PATCH 2/2] Log jit misses at runtime instead of compile time. Really, it could be very different after all... this shouldn't be all that slow, I guess. --- Core/MIPS/x86/Jit.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index e372bd63f1..6c316a2fa4 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -86,6 +86,15 @@ void JitBreakpoint() } } +static void JitLogMiss(u32 op) +{ + if (USE_JIT_MISSMAP) + notJitOps[MIPSGetName(op)]++; + + MIPSInterpretFunc func = MIPSGetInterpretFunc(op); + func(op); +} + Jit::Jit(MIPSState *mips) : blocks(mips), mips_(mips) { blocks.Init(); @@ -210,16 +219,18 @@ void Jit::Comp_RunBlock(u32 op) void Jit::Comp_Generic(u32 op) { - if (USE_JIT_MISSMAP) - notJitOps[MIPSGetName(op)]++; - FlushAll(); MIPSInterpretFunc func = MIPSGetInterpretFunc(op); if (func) { MOV(32, M(&mips_->pc), Imm32(js.compilerPC)); - ABI_CallFunctionC((void *)func, op); + if (USE_JIT_MISSMAP) + ABI_CallFunctionC((void *)&JitLogMiss, op); + else + ABI_CallFunctionC((void *)func, op); } + else + _dbg_assert_msg_(JIT, 0, "Trying to compile instruction that can't be interpreted"); } void Jit::WriteExit(u32 destination, int exit_num)