diff --git a/src/core/core.cpp b/src/core/core.cpp index 65a69d078c..8aef26d93f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -956,19 +956,17 @@ void System::RegisterHostThread() { impl->kernel.RegisterHostThread(); } -void System::EnterCPUProfile() { #if MICROPROFILE_ENABLED +void System::EnterCPUProfile() { std::size_t core = impl->kernel.GetCurrentHostThreadID(); impl->dynarmic_ticks[core] = MicroProfileEnter(impl->microprofile_cpu[core]); -#endif } void System::ExitCPUProfile() { -#if MICROPROFILE_ENABLED std::size_t core = impl->kernel.GetCurrentHostThreadID(); MicroProfileLeave(impl->microprofile_cpu[core], impl->dynarmic_ticks[core]); -#endif } +#endif bool System::IsMulticore() const { return impl->is_multicore; diff --git a/src/core/core.h b/src/core/core.h index b33cb0c4f7..3f1a3f0388 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -396,11 +396,13 @@ public: /// Register a host thread as an auxiliary thread. void RegisterHostThread(); +#if MICROPROFILE_ENABLED /// Enter CPU Microprofile void EnterCPUProfile(); /// Exit CPU Microprofile void ExitCPUProfile(); +#endif /// Tells if system is running on multicore. [[nodiscard]] bool IsMulticore() const; diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 8aec3d1f47..7a851e9b02 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -1278,17 +1278,15 @@ void KernelCore::ExceptionalExitApplication() { SuspendEmulation(true); } -void KernelCore::EnterSVCProfile() { #if MICROPROFILE_ENABLED +void KernelCore::EnterSVCProfile() { impl->svc_ticks[CurrentPhysicalCoreIndex()] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC)); -#endif } void KernelCore::ExitSVCProfile() { -#if MICROPROFILE_ENABLED MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[CurrentPhysicalCoreIndex()]); -#endif } +#endif Init::KSlabResourceCounts& KernelCore::SlabResourceCounts() { return impl->slab_resource_counts; diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 57182c0c8d..e11241d6aa 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -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; diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 0f45a32494..3321032563 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -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) { diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index c55dc0c8ad..b1ce1e9daa 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -4428,7 +4428,9 @@ void Call(Core::System& system, u32 imm) { std::array 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); }