From a446b096cb0ad52c08aca5984a65d03f18639e69 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 13 May 2018 00:46:33 +1000 Subject: [PATCH] Jit64: Invalidate cached constant values w/o host register on flush If we don't flush the values, they persist in the register cache, potentially resulting in the values being out of sync with PPCSTATE. This was causing random crashes in games, mainly booting, when certain JIT instructions were disabled, or forced to fall back to interpreter. --- Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index 6c75530369..5cdc71dd6b 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -101,6 +101,13 @@ void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush) ASSERT_MSG(DYNA_REC, 0, "Jit64 - Flush unhandled case, reg %u PC: %08x", i, PC); } } + else if (m_regs[i].location.IsImm()) + { + // We can have a cached value without a host register through speculative constants. + // It must be cleared when flushing, otherwise it may be out of sync with PPCSTATE, + // if PPCSTATE is modified externally (e.g. fallback to interpreter). + m_regs[i].location = GetDefaultLocation(i); + } } }