From 1c4b430984b6d7131668953c1a4af55a831df988 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 7 Dec 2015 09:26:25 +0100 Subject: [PATCH] profiler: plug recompiler with new perf infra Only EE/IOP support by block profiling v2: cast wxString with ToUTF8 (windows) --- pcsx2/System.cpp | 4 ++++ pcsx2/x86/iR3000A.cpp | 10 ++++++++++ pcsx2/x86/ix86-32/iR5900-32.cpp | 12 ++++++++++++ pcsx2/x86/microVU.cpp | 5 +++++ 4 files changed, 31 insertions(+) diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 277312c90c..fff21a7e4a 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -27,6 +27,7 @@ #include "System/RecTypes.h" #include "Utilities/MemsetFast.inl" +#include "Utilities/Perf.h" // -------------------------------------------------------------------------------------- @@ -56,6 +57,9 @@ void RecompiledCodeReserve::_registerProfiler() if (m_profiler_name.IsEmpty() || !IsOk()) return; ProfilerRegisterSource( m_profiler_name, m_baseptr, GetReserveSizeInBytes() ); m_profiler_registered = true; + + // Could potentially be integrated into ProfilerRegisterSource + Perf::any.map((uptr)m_baseptr, GetReserveSizeInBytes(), m_profiler_name.ToUTF8()); } void RecompiledCodeReserve::_termProfiler() diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index e55ce1327a..9bca128013 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -36,6 +36,7 @@ #include "NakedAsm.h" #include "AppConfig.h" +#include "Utilities/Perf.h" using namespace x86Emitter; @@ -361,6 +362,8 @@ static void _DynGen_Dispatchers() HostSys::MemProtectStatic( iopRecDispatchers, PageAccess_ExecOnly() ); recBlocks.SetJITCompile( iopJITCompile ); + + Perf::any.map((uptr)&iopRecDispatchers, 4096, "IOP Dispatcher"); } //////////////////////////////////////////////////// @@ -812,6 +815,8 @@ void recResetIOP() { DevCon.WriteLn( "iR3000A Recompiler reset." ); + Perf::iop.reset(); + recAlloc(); recMem->Reset(); @@ -868,6 +873,9 @@ static void recShutdown() safe_free( s_pInstCache ); s_nInstCacheSize = 0; + + // FIXME Warning thread unsafe + Perf::dump(); } static void iopClearRecLUT(BASEBLOCK* base, int count) @@ -1411,6 +1419,8 @@ StartRecomp: pxAssert(xGetPtr() - recPtr < _64kb); s_pCurBlockEx->x86size = xGetPtr() - recPtr; + Perf::iop.map(s_pCurBlockEx->fnptr, s_pCurBlockEx->x86size, s_pCurBlockEx->startpc); + recPtr = xGetPtr(); pxAssert( (g_psxHasConstReg&g_psxFlushedConstReg) == g_psxHasConstReg ); diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 4569708d82..0a1da6de6b 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -41,6 +41,7 @@ #include "Utilities/MemsetFast.inl" +#include "Utilities/Perf.h" using namespace x86Emitter; @@ -574,6 +575,8 @@ static void _DynGen_Dispatchers() HostSys::MemProtectStatic( eeRecDispatchers, PageAccess_ExecOnly() ); recBlocks.SetJITCompile( JITCompile ); + + Perf::any.map((uptr)&eeRecDispatchers, 4096, "EE Dispatcher"); } @@ -699,6 +702,8 @@ static bool eeCpuExecuting = false; //////////////////////////////////////////////////// static void recResetRaw() { + Perf::ee.reset(); + EE::Profiler.Reset(); recAlloc(); @@ -744,6 +749,9 @@ static void recShutdown() safe_aligned_free( recConstBuf ); safe_free( s_pInstCache ); s_nInstCacheSize = 0; + + // FIXME Warning thread unsafe + Perf::dump(); } static void recResetEE() @@ -840,6 +848,9 @@ static void recExecute() if(m_cpuException) m_cpuException->Rethrow(); if(m_Exception) m_Exception->Rethrow(); + + // FIXME Warning thread unsafe + Perf::dump(); #endif EE::Profiler.Print(); @@ -2198,6 +2209,7 @@ StartRecomp: iDumpBlock(s_pCurBlockEx->startpc, s_pCurBlockEx->size*4, s_pCurBlockEx->fnptr, s_pCurBlockEx->x86size); } #endif + Perf::ee.map(s_pCurBlockEx->fnptr, s_pCurBlockEx->x86size, s_pCurBlockEx->startpc); recPtr = xGetPtr(); diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index 8b71c5ca1d..f9e43bbdf2 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -18,6 +18,8 @@ #include "PrecompiledHeader.h" #include "microVU.h" +#include "Utilities/Perf.h" + //------------------------------------------------------------------ // Micro VU - Main Functions //------------------------------------------------------------------ @@ -73,6 +75,9 @@ void mVUreset(microVU& mVU, bool resetReserve) { // Restore reserve to uncommitted state if (resetReserve) mVU.cache_reserve->Reset(); + + if (mVU.index) Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU1 Dispatcher"); + else Perf::any.map((uptr)&mVU.dispCache, mVUdispCacheSize, "mVU0 Dispatcher"); x86SetPtr(mVU.dispCache); mVUdispatcherA(mVU);