dolphin/Source/Core/Common/JitRegister.h
JosJuice c54dc9db60 JitRegister: Check IsEnabled before constructing string
Without this, every time we finalize a JIT block, we have to allocate
memory for a string and format the string.
2026-01-11 21:01:49 +01:00

40 lines
1.0 KiB
C++

// Copyright 2014 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string>
#include <fmt/format.h>
#include "Common/CommonTypes.h"
namespace Common::JitRegister
{
void Init(const std::string& perf_dir);
void Shutdown();
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::format_string<Args...> format,
Args&&... args)
{
if (!IsEnabled())
return;
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::format_string<Args...> format,
Args&&... args)
{
if (!IsEnabled())
return;
u32 code_size = (u32)((const char*)end - (const char*)start);
Register(start, code_size, fmt::format(format, std::forward<Args>(args)...));
}
} // namespace Common::JitRegister