diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index c426dfb7d7..7110040081 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -19,6 +19,7 @@ #include "Breakpoints.h" #include "SymbolMap.h" #include "FixedSizeUnorderedSet.h" +#include "../MIPS/JitCommon/JitCommon.h" #include #define MAX_BREAKPOINTS 16 @@ -73,6 +74,7 @@ void CBreakPoints::RemoveBreakPoint(u32 _iAddress) if (m_iBreakPoints[i].iAddress == _iAddress) { m_iBreakPoints.remove(m_iBreakPoints[i]); + InvalidateJit(_iAddress); break; } } @@ -81,6 +83,7 @@ void CBreakPoints::RemoveBreakPoint(u32 _iAddress) void CBreakPoints::ClearAllBreakPoints() { m_iBreakPoints.clear(); + InvalidateJit(); } MemCheck *CBreakPoints::GetMemCheck(u32 address) @@ -123,5 +126,20 @@ void CBreakPoints::AddBreakPoint(u32 _iAddress, bool temp) pt.iAddress = _iAddress; m_iBreakPoints.insert(pt); + InvalidateJit(_iAddress); } } + +void CBreakPoints::InvalidateJit(u32 _iAddress) +{ + // Don't want to clear cache while running, I think? + if (MIPSComp::jit && coreState == CORE_STEPPING) + MIPSComp::jit->ClearCacheAt(_iAddress); +} + +void CBreakPoints::InvalidateJit() +{ + // Don't want to clear cache while running, I think? + if (MIPSComp::jit && coreState == CORE_STEPPING) + MIPSComp::jit->ClearCache(); +} diff --git a/Core/Debugger/Breakpoints.h b/Core/Debugger/Breakpoints.h index 16103017c3..c931010301 100644 --- a/Core/Debugger/Breakpoints.h +++ b/Core/Debugger/Breakpoints.h @@ -80,6 +80,9 @@ public: static void RemoveBreakPoint(u32 _iAddress); static void ClearAllBreakPoints(); + + static void InvalidateJit(u32 _iAddress); + static void InvalidateJit(); }; diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index cb0373ba43..f4c9d8c971 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -76,6 +76,12 @@ void Jit::ClearCache() GenerateFixedCode(); } +void Jit::ClearCacheAt(u32 em_address) +{ + // TODO: Properly. + ClearCache(); +} + void Jit::CompileAt(u32 addr) { u32 op = Memory::Read_Instruction(addr); diff --git a/Core/MIPS/ARM/ArmJit.h b/Core/MIPS/ARM/ArmJit.h index f92ef44e5f..a6a9116b32 100644 --- a/Core/MIPS/ARM/ArmJit.h +++ b/Core/MIPS/ARM/ArmJit.h @@ -89,6 +89,7 @@ public: ArmJitBlockCache *GetBlockCache() { return &blocks; } void ClearCache(); + void ClearCacheAt(u32 em_address); private: void GenerateFixedCode(); diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index 9e9963bef1..edae212e3c 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -61,6 +61,12 @@ void Jit::ClearCache() ClearCodeSpace(); } +void Jit::ClearCacheAt(u32 em_address) +{ + // TODO: Properly. + ClearCache(); +} + void Jit::CompileAt(u32 addr) { u32 op = Memory::Read_Instruction(addr); diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index 9f3281830f..60f9f5ea60 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -95,6 +95,7 @@ public: AsmRoutineManager &Asm() { return asm_; } void ClearCache(); + void ClearCacheAt(u32 em_address); private: void FlushAll(); diff --git a/Core/MIPS/x86/JitCache.cpp b/Core/MIPS/x86/JitCache.cpp index cd3d60039b..8fff393dcc 100644 --- a/Core/MIPS/x86/JitCache.cpp +++ b/Core/MIPS/x86/JitCache.cpp @@ -62,7 +62,7 @@ using namespace Gen; bool JitBlock::ContainsAddress(u32 em_address) { - // WARNING - THIS DOES NOT WORK WITH INLINING ENABLED. + // WARNING - THIS DOES NOT WORK WITH JIT INLINING ENABLED. return (em_address >= originalAddress && em_address < originalAddress + 4 * originalSize); } diff --git a/Core/MIPS/x86/JitCache.h b/Core/MIPS/x86/JitCache.h index a447f74115..d508b83111 100644 --- a/Core/MIPS/x86/JitCache.h +++ b/Core/MIPS/x86/JitCache.h @@ -118,7 +118,7 @@ public: int GetBlockNumberFromStartAddress(u32 em_address); // slower, but can get numbers from within blocks, not just the first instruction. - // WARNING! WILL NOT WORK WITH INLINING ENABLED (not yet a feature but will be soon) + // WARNING! WILL NOT WORK WITH JIT INLINING ENABLED (not yet a feature but will be soon) // Returns a list of block numbers - only one block can start at a particular address, but they CAN overlap. // This one is slow so should only be used for one-shots from the debugger UI, not for anything during runtime. void GetBlockNumbersFromAddress(u32 em_address, std::vector *block_numbers); @@ -126,7 +126,7 @@ public: u32 GetOriginalFirstOp(int block_num); CompiledCode GetCompiledCodeFromBlock(int block_num); - // DOES NOT WORK CORRECTLY WITH INLINING + // DOES NOT WORK CORRECTLY WITH JIT INLINING void InvalidateICache(u32 address, const u32 length); void DestroyBlock(int block_num, bool invalidate);