add support for JIT profiling with VTune
This commit is contained in:
parent
c9b918d305
commit
6944fdbe78
|
@ -67,6 +67,13 @@ endif()
|
||||||
|
|
||||||
if (ENABLE_JIT)
|
if (ENABLE_JIT)
|
||||||
add_definitions(-DJIT_ENABLED)
|
add_definitions(-DJIT_ENABLED)
|
||||||
|
|
||||||
|
option(ENABLE_JIT_PROFILING "Enable JIT profiling with VTune" OFF)
|
||||||
|
|
||||||
|
if (ENABLE_JIT_PROFILING)
|
||||||
|
include(cmake/FindVTune.cmake)
|
||||||
|
add_definitions(-DJIT_PROFILING_ENABLED)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
if (CMAKE_BUILD_TYPE STREQUAL Release)
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
find_path(VTUNE_PATH "")
|
||||||
|
|
||||||
|
include_directories("${VTUNE_PATH}/include")
|
||||||
|
link_directories("${VTUNE_PATH}/lib64")
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../Config.h"
|
#include "../Config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "../dolphin/CommonFuncs.h"
|
#include "../dolphin/CommonFuncs.h"
|
||||||
|
|
||||||
|
@ -298,6 +299,10 @@ Compiler::Compiler()
|
||||||
SetJumpTarget(und);
|
SetJumpTarget(und);
|
||||||
MOV(32, R(RSCRATCH3), MComplex(RCPU, RSCRATCH2, SCALE_4, offsetof(ARM, R_UND)));
|
MOV(32, R(RSCRATCH3), MComplex(RCPU, RSCRATCH2, SCALE_4, offsetof(ARM, R_UND)));
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
CreateMethod("ReadBanked", ReadBanked);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// RSCRATCH mode
|
// RSCRATCH mode
|
||||||
|
@ -341,6 +346,10 @@ Compiler::Compiler()
|
||||||
MOV(32, MComplex(RCPU, RSCRATCH2, SCALE_4, offsetof(ARM, R_UND)), R(RSCRATCH3));
|
MOV(32, MComplex(RCPU, RSCRATCH2, SCALE_4, offsetof(ARM, R_UND)), R(RSCRATCH3));
|
||||||
CLC();
|
CLC();
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
CreateMethod("WriteBanked", WriteBanked);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int consoleType = 0; consoleType < 2; consoleType++)
|
for (int consoleType = 0; consoleType < 2; consoleType++)
|
||||||
|
@ -401,6 +410,10 @@ Compiler::Compiler()
|
||||||
ABI_PopRegistersAndAdjustStack(CallerSavedPushRegs, 8);
|
ABI_PopRegistersAndAdjustStack(CallerSavedPushRegs, 8);
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
CreateMethod("FastMemStorePatch%d_%d_%d", PatchedStoreFuncs[consoleType][num][size][reg], num, size, reg);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int signextend = 0; signextend < 2; signextend++)
|
for (int signextend = 0; signextend < 2; signextend++)
|
||||||
{
|
{
|
||||||
PatchedLoadFuncs[consoleType][num][size][signextend][reg] = GetWritableCodePtr();
|
PatchedLoadFuncs[consoleType][num][size][signextend][reg] = GetWritableCodePtr();
|
||||||
|
@ -439,6 +452,10 @@ Compiler::Compiler()
|
||||||
else
|
else
|
||||||
MOVZX(32, 8 << size, rdMapped, R(RSCRATCH));
|
MOVZX(32, 8 << size, rdMapped, R(RSCRATCH));
|
||||||
RET();
|
RET();
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
CreateMethod("FastMemLoadPatch%d_%d_%d_%d", PatchedLoadFuncs[consoleType][num][size][signextend][reg], num, size, reg, signextend);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -668,6 +685,28 @@ void Compiler::Comp_SpecialBranchBehaviour(bool taken)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
void Compiler::CreateMethod(const char* namefmt, void* start, ...)
|
||||||
|
{
|
||||||
|
if (iJIT_IsProfilingActive())
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, start);
|
||||||
|
char name[64];
|
||||||
|
vsprintf(name, namefmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
iJIT_Method_Load method = {0};
|
||||||
|
method.method_id = iJIT_GetNewMethodID();
|
||||||
|
method.method_name = name;
|
||||||
|
method.method_load_address = start;
|
||||||
|
method.method_size = GetWritableCodePtr() - (u8*)start;
|
||||||
|
|
||||||
|
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, (void*)&method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[], int instrsCount, bool hasMemoryInstr)
|
JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[], int instrsCount, bool hasMemoryInstr)
|
||||||
{
|
{
|
||||||
if (NearSize - (GetCodePtr() - NearStart) < 1024 * 32) // guess...
|
if (NearSize - (GetCodePtr() - NearStart) < 1024 * 32) // guess...
|
||||||
|
@ -805,6 +844,10 @@ JitBlockEntry Compiler::CompileBlock(ARM* cpu, bool thumb, FetchedInstr instrs[]
|
||||||
ADD(32, MDisp(RCPU, offsetof(ARM, Cycles)), Imm32(ConstantCycles));
|
ADD(32, MDisp(RCPU, offsetof(ARM, Cycles)), Imm32(ConstantCycles));
|
||||||
JMP((u8*)ARM_Ret, true);
|
JMP((u8*)ARM_Ret, true);
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
CreateMethod("JIT_Block_%d_%d_%08X", (void*)res, Num, Thumb, instrs[0].Addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*FILE* codeout = fopen("codeout", "a");
|
/*FILE* codeout = fopen("codeout", "a");
|
||||||
fprintf(codeout, "beginning block argargarg__ %x!!!", instrs[0].Addr);
|
fprintf(codeout, "beginning block argargarg__ %x!!!", instrs[0].Addr);
|
||||||
fwrite((u8*)res, GetWritableCodePtr() - (u8*)res, 1, codeout);
|
fwrite((u8*)res, GetWritableCodePtr() - (u8*)res, 1, codeout);
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
#include "../ARMJIT_Internal.h"
|
#include "../ARMJIT_Internal.h"
|
||||||
#include "../ARMJIT_RegisterCache.h"
|
#include "../ARMJIT_RegisterCache.h"
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
#include <jitprofiling.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace ARMJIT
|
namespace ARMJIT
|
||||||
|
@ -230,6 +234,10 @@ public:
|
||||||
|
|
||||||
u8* RewriteMemAccess(u8* pc);
|
u8* RewriteMemAccess(u8* pc);
|
||||||
|
|
||||||
|
#ifdef JIT_PROFILING_ENABLED
|
||||||
|
void CreateMethod(const char* namefmt, void* start, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
u8* FarCode;
|
u8* FarCode;
|
||||||
u8* NearCode;
|
u8* NearCode;
|
||||||
u32 FarSize;
|
u32 FarSize;
|
||||||
|
|
|
@ -124,3 +124,7 @@ else()
|
||||||
target_link_libraries(core rt)
|
target_link_libraries(core rt)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (ENABLE_JIT_PROFILING)
|
||||||
|
target_link_libraries(core jitprofiling)
|
||||||
|
endif()
|
Loading…
Reference in New Issue