diff --git a/include/cpu_dynarmic.hpp b/include/cpu_dynarmic.hpp index 7bed8704..8f1e277b 100644 --- a/include/cpu_dynarmic.hpp +++ b/include/cpu_dynarmic.hpp @@ -173,11 +173,18 @@ public: void clearCache() { jit->ClearCache(); } void runFrame() { - env.ticksLeft = ticksPerSec / 60; + env.ticksLeft = ticksPerSec / 60; + execute: + const auto exitReason = jit->Run(); - const auto exitReason = jit->Run(); - if (static_cast(exitReason) != 0) [[unlikely]] { - Helpers::panic("Exit reason: %d\nPC: %08X", static_cast(exitReason), getReg(15)); - } - } + if (static_cast(exitReason) != 0) [[unlikely]] { + // Cache invalidation needs to exit the JIT so it returns a CacheInvalidation HaltReason. In our case, we just go back to executing + // The goto might be terrible but it does guarantee that this does not recursively call run and crash, instead getting optimized to a jump + if (Dynarmic::Has(exitReason, Dynarmic::HaltReason::CacheInvalidation)) { + goto execute; + } else { + Helpers::panic("Exit reason: %d\nPC: %08X", static_cast(exitReason), getReg(15)); + } + } + } }; \ No newline at end of file