diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.cpp index 2822cedeed..b209a7299b 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.cpp @@ -48,10 +48,14 @@ #if defined USE_OPROFILE && USE_OPROFILE #include + +op_agent_t agent; #endif -#if defined USE_OPROFILE && USE_OPROFILE - op_agent_t agent; +#if defined USE_VTUNE +#include +#pragma comment(lib, "libittnotify.lib") +#pragma comment(lib, "jitprofiling.lib") #endif using namespace Gen; @@ -121,6 +125,10 @@ bool JitBlock::ContainsAddress(u32 em_address) #if defined USE_OPROFILE && USE_OPROFILE op_close_agent(agent); #endif + +#ifdef USE_VTUNE + iJIT_NotifyEvent(iJVM_EVENT_TYPE_SHUTDOWN, NULL); +#endif } // This clears the JIT cache. It's called from JitCache.cpp when the JIT cache @@ -232,6 +240,20 @@ bool JitBlock::ContainsAddress(u32 em_address) op_write_native_code(agent, buf, (uint64_t)blockStart, blockStart, b.codeSize); #endif + +#ifdef USE_VTUNE + sprintf(b.blockName, "EmuCode_0x%08x", b.originalAddress); + + iJIT_Method_Load jmethod = {0}; + jmethod.method_id = iJIT_GetNewMethodID(); + jmethod.class_file_name = ""; + jmethod.source_file_name = __FILE__; + jmethod.method_load_address = (void*)blockCodePointers[block_num]; + jmethod.method_size = b.codeSize; + jmethod.line_number_size = 0; + jmethod.method_name = b.blockName; + iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&jmethod); +#endif } const u8 **JitBlockCache::GetCodePointers() diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.h b/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.h index a62e2713b4..cc373d6114 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.h +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitCache.h @@ -24,6 +24,9 @@ #include "../Gekko.h" #include "../PPCAnalyst.h" +// Define this in order to get VTune profile support for the Jit generated code. +// Add the VTune include/lib directories to the project directories to get this to build. +// #define USE_VTUNE // emulate CPU with unlimited instruction cache // the only way to invalidate a region is the "icbi" instruction @@ -66,6 +69,10 @@ struct JitBlock u64 ticStop; // for profiling - time. u64 ticCounter; // for profiling - time. #endif + +#ifdef USE_VTUNE + char blockName[32]; +#endif }; typedef void (*CompiledCode)();