Skip to content

Commit

Permalink
fixup! JitRegister: Use fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
merryhime committed Feb 16, 2022
1 parent e1045d8 commit 3e023c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Source/Core/Common/JitRegister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,13 @@ bool IsEnabled()
return s_is_enabled;
}

void RegisterV(const void* base_address, u32 code_size, fmt::string_view format,
fmt::format_args 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 = fmt::vformat(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
Expand Down
21 changes: 11 additions & 10 deletions Source/Core/Common/JitRegister.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once
#include <fmt/format.h>
#include <stdarg.h>

#include <string>

#include <fmt/format.h>

#include "Common/CommonTypes.h"

namespace JitRegister
{
void Init(const std::string& perf_dir);
void Shutdown();
void RegisterV(const void* base_address, u32 code_size, fmt::string_view format,
fmt::format_args args);
void Register(const void* base_address, u32 code_size, const std::string& symbol_name);
bool IsEnabled();

template <typename... Args>
inline void Register(const void* base_address, u32 code_size, fmt::string_view format,
const Args&... args)
inline void Register(const void* base_address, u32 code_size, fmt::format_string<Args...> format,
Args&&... args)
{
RegisterV(base_address, code_size, format, fmt::make_format_args(args...));
Register(base_address, code_size, fmt::format(format, std::forward<Args>(args)...));
}

template <typename... Args>
inline void Register(const void* start, const void* end, fmt::string_view format,
const Args&... args)
inline void Register(const void* start, const void* end, fmt::format_string<Args...> format,
Args&&... args)
{
u32 code_size = (u32)((const char*)end - (const char*)start);
RegisterV(start, code_size, format, fmt::make_format_args(args...));
Register(start, code_size, fmt::format(format, std::forward<Args>(args)...));
}
} // namespace JitRegister

0 comments on commit 3e023c4

Please sign in to comment.