Add cmake option to enable microprofile (#179)

Backported from dd9c743041.

Co-authored-by: PabloMK7 <hackyglitch2@gmail.com>

Co-authored-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/179
Co-authored-by: Gamer64 <gamer64@eden-emu.dev>
Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
This commit is contained in:
Gamer64 2025-08-02 17:22:38 +02:00 committed by crueter
parent b32a667d6f
commit 1f34d836b4
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
17 changed files with 64 additions and 11 deletions

View file

@ -1278,6 +1278,7 @@ void KernelCore::ExceptionalExitApplication() {
SuspendEmulation(true);
}
#if MICROPROFILE_ENABLED
void KernelCore::EnterSVCProfile() {
impl->svc_ticks[CurrentPhysicalCoreIndex()] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC));
}
@ -1285,6 +1286,7 @@ void KernelCore::EnterSVCProfile() {
void KernelCore::ExitSVCProfile() {
MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[CurrentPhysicalCoreIndex()]);
}
#endif
Init::KSlabResourceCounts& KernelCore::SlabResourceCounts() {
return impl->slab_resource_counts;

View file

@ -271,9 +271,11 @@ public:
bool IsShuttingDown() const;
#if MICROPROFILE_ENABLED
void EnterSVCProfile();
void ExitSVCProfile();
#endif
/// Workaround for single-core mode when preempting threads while idle.
bool IsPhantomModeForSingleCore() const;

View file

@ -27,7 +27,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
interface->Initialize();
const auto EnterContext = [&]() {
#if MICROPROFILE_ENABLED
system.EnterCPUProfile();
#endif
// Lock the core context.
std::scoped_lock lk{m_guard};
@ -59,7 +61,9 @@ void PhysicalCore::RunThread(Kernel::KThread* thread) {
m_arm_interface = nullptr;
m_current_thread = nullptr;
#if MICROPROFILE_ENABLED
system.ExitCPUProfile();
#endif
};
while (true) {

View file

@ -4428,7 +4428,9 @@ void Call(Core::System& system, u32 imm) {
std::array<uint64_t, 8> args;
kernel.CurrentPhysicalCore().SaveSvcArguments(process, args);
#if MICROPROFILE_ENABLED
kernel.EnterSVCProfile();
#endif
if (process.Is64Bit()) {
Call64(system, imm, args);
@ -4436,7 +4438,9 @@ void Call(Core::System& system, u32 imm) {
Call32(system, imm, args);
}
#if MICROPROFILE_ENABLED
kernel.ExitSVCProfile();
#endif
kernel.CurrentPhysicalCore().LoadSvcArguments(process, args);
}