Merge branch 'master' of github.com:benvanik/xenia

This commit is contained in:
DrChat 2017-03-16 17:47:36 -05:00
commit 271d78fd39
2 changed files with 32 additions and 0 deletions

View File

@ -19,6 +19,11 @@ project("xenia-cpu-backend-x64")
"CAPSTONE_USE_SYS_DYN_MEM",
"XBYAK_NO_OP_NAMES",
})
-- Enable VTune, if it's installed.
if os.isdir(project_root.."/third_party/vtune") then
defines { "ENABLE_VTUNE=1" }
end
includedirs({
project_root.."/third_party/capstone/include",
project_root.."/third_party/gflags/src",

View File

@ -12,12 +12,18 @@
#include <cstdlib>
#include <cstring>
#if ENABLE_VTUNE
#include "third_party/vtune/include/jitprofiling.h"
#pragma comment(lib, "../third_party/vtune/lib64/jitprofiling.lib")
#endif
#include "xenia/base/assert.h"
#include "xenia/base/clock.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
#include "xenia/base/memory.h"
#include "xenia/cpu/function.h"
#include "xenia/cpu/module.h"
namespace xe {
namespace cpu {
@ -190,6 +196,27 @@ void* X64CodeCache::PlaceGuestCode(uint32_t guest_address, void* machine_code,
unwind_reservation);
}
#if ENABLE_VTUNE
if (iJIT_IsProfilingActive() == iJIT_SAMPLING_ON) {
std::string method_name;
if (function_info && function_info->name().size() != 0) {
method_name = function_info->name();
} else {
method_name = xe::format_string("sub_%.8X", guest_address);
}
iJIT_Method_Load_V2 method = {0};
method.method_id = iJIT_GetNewMethodID();
method.method_load_address = code_address;
method.method_size = uint32_t(code_size);
method.method_name = const_cast<char*>(method_name.data());
method.module_name = function_info
? (char*)function_info->module()->name().c_str()
: nullptr;
iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED_V2, (void*)&method);
}
#endif
// Now that everything is ready, fix up the indirection table.
// Note that we do support code that doesn't have an indirection fixup, so
// ignore those when we see them.