diff --git a/Source/Core/Common/JitRegister.cpp b/Source/Core/Common/JitRegister.cpp index eb5845d5cb..0dd5557f11 100644 --- a/Source/Core/Common/JitRegister.cpp +++ b/Source/Core/Common/JitRegister.cpp @@ -81,15 +81,13 @@ bool IsEnabled() return s_is_enabled; } -void RegisterV(const void* base_address, u32 code_size, const char* format, va_list args) +void Register(const void* base_address, u32 code_size, const std::string& symbol_name) { #if !(defined USE_OPROFILE && USE_OPROFILE) && !defined(USE_VTUNE) if (!s_perf_map_file.IsOpen()) return; #endif - std::string symbol_name = StringFromFormatV(format, args); - #if defined USE_OPROFILE && USE_OPROFILE op_write_native_code(s_agent, symbol_name.c_str(), (u64)base_address, base_address, code_size); #endif diff --git a/Source/Core/Common/JitRegister.h b/Source/Core/Common/JitRegister.h index 084f4486fa..49dfb5ab44 100644 --- a/Source/Core/Common/JitRegister.h +++ b/Source/Core/Common/JitRegister.h @@ -2,31 +2,32 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#include + #include + +#include + #include "Common/CommonTypes.h" namespace JitRegister { void Init(const std::string& perf_dir); void Shutdown(); -void RegisterV(const void* base_address, u32 code_size, const char* format, va_list args); +void Register(const void* base_address, u32 code_size, const std::string& symbol_name); bool IsEnabled(); -inline void Register(const void* base_address, u32 code_size, const char* format, ...) +template +inline void Register(const void* base_address, u32 code_size, fmt::format_string format, + Args&&... args) { - va_list args; - va_start(args, format); - RegisterV(base_address, code_size, format, args); - va_end(args); + Register(base_address, code_size, fmt::format(format, std::forward(args)...)); } -inline void Register(const void* start, const void* end, const char* format, ...) +template +inline void Register(const void* start, const void* end, fmt::format_string format, + Args&&... args) { - va_list args; - va_start(args, format); u32 code_size = (u32)((const char*)end - (const char*)start); - RegisterV(start, code_size, format, args); - va_end(args); + Register(start, code_size, fmt::format(format, std::forward(args)...)); } } // namespace JitRegister diff --git a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp index b6fc24e89b..124218fb7f 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/Jit64AsmCommon.cpp @@ -369,7 +369,7 @@ const u8* CommonAsmRoutines::GenQuantizedStoreRuntime(bool single, EQuantizeType const u8* load = AlignCode4(); GenQuantizedStore(single, type, -1); RET(); - JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedStore_%i_%i", type, single); + JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedStore_{}_{}", type, single); return load; } @@ -400,7 +400,7 @@ const u8* CommonAsmRoutines::GenQuantizedLoadRuntime(bool single, EQuantizeType const u8* load = AlignCode4(); GenQuantizedLoad(single, type, -1); RET(); - JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedLoad_%i_%i", type, single); + JitRegister::Register(start, GetCodePtr(), "JIT_QuantizedLoad_{}_{}", type, single); return load; } diff --git a/Source/Core/Core/PowerPC/Jit64Common/TrampolineCache.cpp b/Source/Core/Core/PowerPC/Jit64Common/TrampolineCache.cpp index d30b1eacb9..faf0b7ec9e 100644 --- a/Source/Core/Core/PowerPC/Jit64Common/TrampolineCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64Common/TrampolineCache.cpp @@ -48,7 +48,7 @@ const u8* TrampolineCache::GenerateReadTrampoline(const TrampolineInfo& info) JMP(info.start + info.len, true); - JitRegister::Register(trampoline, GetCodePtr(), "JIT_ReadTrampoline_%x", info.pc); + JitRegister::Register(trampoline, GetCodePtr(), "JIT_ReadTrampoline_{:x}", info.pc); return trampoline; } @@ -67,6 +67,6 @@ const u8* TrampolineCache::GenerateWriteTrampoline(const TrampolineInfo& info) JMP(info.start + info.len, true); - JitRegister::Register(trampoline, GetCodePtr(), "JIT_WriteTrampoline_%x", info.pc); + JitRegister::Register(trampoline, GetCodePtr(), "JIT_WriteTrampoline_{:x}", info.pc); return trampoline; } diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index de55900846..ca090547f9 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -131,12 +131,12 @@ void JitBaseBlockCache::FinalizeBlock(JitBlock& block, bool block_link, if (JitRegister::IsEnabled() && (symbol = g_symbolDB.GetSymbolFromAddr(block.effectiveAddress)) != nullptr) { - JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_%s_%08x", + JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_{}_{:08x}", symbol->function_name.c_str(), block.physicalAddress); } else { - JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_%08x", + JitRegister::Register(block.checkedEntry, block.codeSize, "JIT_PPC_{:08x}", block.physicalAddress); } } diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index 40ae508219..7a4929361d 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -50,9 +50,8 @@ VertexLoaderX64::VertexLoaderX64(const TVtxDesc& vtx_desc, const VAT& vtx_att) GenerateVertexLoader(); WriteProtect(); - const std::string name = - fmt::format("VertexLoaderX64\nVtx desc: \n{}\nVAT:\n{}", vtx_desc, vtx_att); - JitRegister::Register(region, GetCodePtr(), name.c_str()); + JitRegister::Register(region, GetCodePtr(), "VertexLoaderX64\nVtx desc: \n{}\nVAT:\n{}", vtx_desc, + vtx_att); } OpArg VertexLoaderX64::GetVertexAddr(CPArray array, VertexComponentFormat attribute)