From c1ddc2678e206eb4eefc519b5ed1368bf42be293 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 27 Feb 2017 22:58:14 +0100 Subject: [PATCH 1/2] JitCache: Fix removing of blocks. --- Source/Core/Core/PowerPC/JitCommon/JitCache.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index 7faf3b1258..af76158faa 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -243,7 +243,16 @@ void JitBaseBlockCache::ErasePhysicalRange(u32 address, u32 length) // And remove the block. DestroyBlock(*block); - block_map.erase(block->physicalAddress); + auto block_map_iter = block_map.equal_range(block->physicalAddress); + while (block_map_iter.first != block_map_iter.second) + { + if (&block_map_iter.first->second == block) + { + block_map.erase(block_map_iter.first); + break; + } + block_map_iter.first++; + } iter = start->second.erase(iter); } else From ffa61fcf57e23659389f694f1c3e76a3d09be336 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 27 Feb 2017 23:46:24 +0100 Subject: [PATCH 2/2] JitCache: Also unlink exits of the current block. We might still be in the current block. This is fine, but the next one might also be invalidated later on. But we may never also call the next one. --- Source/Core/Core/PowerPC/JitCommon/JitCache.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp index af76158faa..54ce8c27f9 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitCache.cpp @@ -315,8 +315,14 @@ void JitBaseBlockCache::LinkBlock(JitBlock& block) void JitBaseBlockCache::UnlinkBlock(const JitBlock& block) { - auto ppp = links_to.equal_range(block.effectiveAddress); + // Unlink all exits of this block. + for (auto& e : block.linkData) + { + WriteLinkBlock(e, nullptr); + } + // Unlink all exits of other blocks which points to this block + auto ppp = links_to.equal_range(block.effectiveAddress); for (auto iter = ppp.first; iter != ppp.second; ++iter) { JitBlock& sourceBlock = *iter->second;