From 7139301692410df9b5f3f7f8e8b0ee4ca507dcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 11 Sep 2024 11:24:11 +0200 Subject: [PATCH] IR interpreter: Replace the assert for downcount with a very predictable branch Fixes breakpoints and other similar things, with a negligible penalty. --- Core/MIPS/IR/IRJit.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/MIPS/IR/IRJit.cpp b/Core/MIPS/IR/IRJit.cpp index 8de1656d86..25a5768a28 100644 --- a/Core/MIPS/IR/IRJit.cpp +++ b/Core/MIPS/IR/IRJit.cpp @@ -279,10 +279,12 @@ void IRJit::RunLoopUntil(u64 globalticks) { if (opcode == MIPS_EMUHACK_OPCODE) { u32 offset = inst & 0x00FFFFFF; // Alternatively, inst - opcode const IRInst *instPtr = blocks_.GetArenaPtr() + offset; - // First op is always downcount, to save one dispatch. - _dbg_assert_(instPtr->op == IROp::Downcount); - mips->downcount -= instPtr->constant; - instPtr++; + // First op is always, except when using breakpoints, downcount, to save one dispatch inside IRInterpret. + // This branch is very cpu-branch-predictor-friendly so this still beats the dispatch. + if (instPtr->op == IROp::Downcount) { + mips->downcount -= instPtr->constant; + instPtr++; + } #ifdef IR_PROFILING IRBlock *block = blocks_.GetBlock(blocks_.GetBlockNumFromOffset(offset)); Instant start = Instant::Now();