mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Improve JIT profiling on Linux
Add JIT object dumping functionality. Add source for objdump interception utility.
This commit is contained in:
parent
14951d8713
commit
11ee1f3eb2
4 changed files with 230 additions and 18 deletions
|
@ -24,6 +24,37 @@ void jit_announce(uptr func, usz size, std::string_view name)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!name.empty())
|
||||
{
|
||||
// If directory ASMJIT doesn't exist, nothing will be written
|
||||
static const fs::file s_asm = []()
|
||||
{
|
||||
fs::remove_all(fs::get_cache_dir() + "/ASMJIT/", false);
|
||||
|
||||
return fs::file(fmt::format("%s/ASMJIT/.objects", fs::get_cache_dir()), fs::rewrite + fs::append);
|
||||
}();
|
||||
|
||||
if (s_asm)
|
||||
{
|
||||
// Dump object: addr + size + bytes
|
||||
s_asm.write(fmt::format("%s%s%s",
|
||||
std::string_view(reinterpret_cast<char*>(&func), 8),
|
||||
std::string_view(reinterpret_cast<char*>(&size), 8),
|
||||
std::string_view(reinterpret_cast<char*>(func), size)));
|
||||
}
|
||||
|
||||
if (s_asm && name[0] != '_')
|
||||
{
|
||||
// Save some objects separately
|
||||
fs::file dump(fmt::format("%s/ASMJIT/%s", fs::get_cache_dir(), name), fs::rewrite);
|
||||
|
||||
if (dump)
|
||||
{
|
||||
dump.write(reinterpret_cast<uchar*>(func), size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
static const fs::file s_map(fmt::format("/tmp/perf-%d.map", getpid()), fs::rewrite + fs::append);
|
||||
|
||||
|
@ -146,17 +177,6 @@ void* jit_runtime_base::_add(asmjit::CodeHolder* code) noexcept
|
|||
}
|
||||
}
|
||||
|
||||
if (!dump_name.empty())
|
||||
{
|
||||
// If directory ASMJIT doesn't exist, nothing will be written
|
||||
fs::file dump(fmt::format("%s/ASMJIT/%s", fs::get_cache_dir(), dump_name), fs::rewrite);
|
||||
|
||||
if (dump)
|
||||
{
|
||||
dump.write(p, codeSize);
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue