diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 9f45d150f6..25b391aac7 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -16,6 +16,7 @@ #include "Common/File.h" #include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" +#include "Common/PerformanceCounter.h" #include "Common/StringUtil.h" #include "Common/x64ABI.h" #include "Core/Core.h" @@ -648,15 +649,17 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc } // Conditionally add profiling code. + b->ticCounter = 0; + b->ticStart = 0; + b->ticStop = 0; if (Profiler::g_ProfileBlocks) { MOV(64, R(RSCRATCH), ImmPtr(&b->runCount)); ADD(32, MatR(RSCRATCH), Imm8(1)); - b->ticCounter = 0; - b->ticStart = 0; - b->ticStop = 0; + // get start tic - PROFILER_QUERY_PERFORMANCE_COUNTER(&b->ticStart); + MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(&b->ticStart))); + ABI_CallFunction(QueryPerformanceCounter); } #if defined(_DEBUG) || defined(DEBUGFAST) || defined(NAN_CHECK) // should help logged stack-traces become more accurate @@ -734,12 +737,18 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc if (Profiler::g_ProfileBlocks) { // WARNING - cmp->branch merging will screw this up. - PROFILER_VPUSH; + BitSet32 registersInUse = CallerSavedRegistersInUse(); + ABI_PushRegistersAndAdjustStack(registersInUse, 0); // get end tic - PROFILER_QUERY_PERFORMANCE_COUNTER(&b->ticStop); + MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(&b->ticStop))); + ABI_CallFunction(QueryPerformanceCounter); // tic counter += (end tic - start tic) - PROFILER_UPDATE_TIME(b); - PROFILER_VPOP; + MOV(64, R(RSCRATCH2), Imm64((u64)b)); + MOV(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticStop))); + SUB(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticStart))); + ADD(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticCounter))); + MOV(64, MDisp(RSCRATCH2, offsetof(struct JitBlock, ticCounter)), R(RSCRATCH)); + ABI_PopRegistersAndAdjustStack(registersInUse, 0); } js.isLastInstruction = true; } diff --git a/Source/Core/Core/PowerPC/Profiler.cpp b/Source/Core/Core/PowerPC/Profiler.cpp index 25a31cf740..0e1a176727 100644 --- a/Source/Core/Core/PowerPC/Profiler.cpp +++ b/Source/Core/Core/PowerPC/Profiler.cpp @@ -5,6 +5,7 @@ #include "Core/PowerPC/Profiler.h" #include +#include "Common/PerformanceCounter.h" #include "Core/PowerPC/JitInterface.h" namespace Profiler diff --git a/Source/Core/Core/PowerPC/Profiler.h b/Source/Core/Core/PowerPC/Profiler.h index 6146bee4d1..33a8b225bb 100644 --- a/Source/Core/Core/PowerPC/Profiler.h +++ b/Source/Core/Core/PowerPC/Profiler.h @@ -10,37 +10,6 @@ #include "Common/CommonTypes.h" -#include "Common/PerformanceCounter.h" - -#if defined(_M_X86_64) - -#define PROFILER_QUERY_PERFORMANCE_COUNTER(pt) \ - MOV(64, R(ABI_PARAM1), Imm64(reinterpret_cast(pt))); \ - ABI_CallFunction(QueryPerformanceCounter) - -// block->ticCounter += block->ticStop - block->ticStart -#define PROFILER_UPDATE_TIME(block) \ - MOV(64, R(RSCRATCH2), Imm64((u64)block)); \ - MOV(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticStop))); \ - SUB(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticStart))); \ - ADD(64, R(RSCRATCH), MDisp(RSCRATCH2, offsetof(struct JitBlock, ticCounter))); \ - MOV(64, MDisp(RSCRATCH2, offsetof(struct JitBlock, ticCounter)), R(RSCRATCH)); - -#define PROFILER_VPUSH \ - BitSet32 registersInUse = CallerSavedRegistersInUse(); \ - ABI_PushRegistersAndAdjustStack(registersInUse, 0); - -#define PROFILER_VPOP ABI_PopRegistersAndAdjustStack(registersInUse, 0); - -#else - -#define PROFILER_QUERY_PERFORMANCE_COUNTER(pt) -#define PROFILER_UPDATE_TIME(b) -#define PROFILER_VPUSH -#define PROFILER_VPOP - -#endif - struct BlockStat { BlockStat(u32 _addr, u64 c, u64 ticks, u64 run, u32 size)