From f9133c1a56985b108244f94dcd420d6647a3db42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 29 Dec 2012 00:09:17 +0100 Subject: [PATCH] Reset JIT before saving/loading state --- Core/MIPS/ARM/Jit.h | 4 +++- Core/MIPS/x86/Jit.h | 3 ++- Core/MIPS/x86/JitCache.cpp | 1 - Core/SaveState.cpp | 9 +++++++-- Core/SaveState.h | 6 +++--- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Core/MIPS/ARM/Jit.h b/Core/MIPS/ARM/Jit.h index d3c9cade66..567d77d7c9 100644 --- a/Core/MIPS/ARM/Jit.h +++ b/Core/MIPS/ARM/Jit.h @@ -94,8 +94,10 @@ public: JitBlockCache *GetBlockCache() { return &blocks; } AsmRoutineManager &Asm() { return asm_; } -private: + void ClearCache(); + +private: void FlushAll(); void WriteExit(u32 destination, int exit_num); diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index 23abe06467..cd5a511efc 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -93,8 +93,9 @@ public: JitBlockCache *GetBlockCache() { return &blocks; } AsmRoutineManager &Asm() { return asm_; } -private: + void ClearCache(); +private: void FlushAll(); void WriteExit(u32 destination, int exit_num); diff --git a/Core/MIPS/x86/JitCache.cpp b/Core/MIPS/x86/JitCache.cpp index 7cae2b5639..c710923972 100644 --- a/Core/MIPS/x86/JitCache.cpp +++ b/Core/MIPS/x86/JitCache.cpp @@ -104,7 +104,6 @@ JitBlockCache::~JitBlockCache() Shutdown(); } - // This clears the JIT cache. It's called from JitCache.cpp when the JIT cache // is full and when saving and loading states. void JitBlockCache::Clear() diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 485aeb726c..aa74d0cebe 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -26,6 +26,7 @@ #include "HW/MemoryStick.h" #include "MemMap.h" #include "MIPS/MIPS.h" +#include "MIPS/JitCommon/JitCommon.h" #include "System.h" namespace SaveState @@ -95,12 +96,12 @@ namespace SaveState CoreTiming::ScheduleEvent_Threadsafe(0, timer); } - void Load(std::string &filename, Callback callback) + void Load(const std::string &filename, Callback callback) { Enqueue(Operation(SAVESTATE_LOAD, filename, callback)); } - void Save(std::string &filename, Callback callback) + void Save(const std::string &filename, Callback callback) { Enqueue(Operation(SAVESTATE_SAVE, filename, callback)); } @@ -132,11 +133,15 @@ namespace SaveState switch (op.type) { case SAVESTATE_LOAD: + if (MIPSComp::jit) + MIPSComp::jit->ClearCache(); INFO_LOG(COMMON, "Loading state from %s", op.filename.c_str()); result = CChunkFileReader::Load(op.filename, REVISION, state); break; case SAVESTATE_SAVE: + if (MIPSComp::jit) + MIPSComp::jit->ClearCache(); INFO_LOG(COMMON, "Saving state to %s", op.filename.c_str()); result = CChunkFileReader::Save(op.filename, REVISION, state); break; diff --git a/Core/SaveState.h b/Core/SaveState.h index 411ad2f88c..82a7021040 100644 --- a/Core/SaveState.h +++ b/Core/SaveState.h @@ -29,11 +29,11 @@ namespace SaveState // Load the specified file into the current state (async.) // Warning: callback will be called on a different thread. - void Load(std::string &filename, Callback callback = NULL); + void Load(const std::string &filename, Callback callback = NULL); // Save the current state to the specified file (async.) // Warning: callback will be called on a different thread. - void Save(std::string &filename, Callback callback = NULL); + void Save(const std::string &filename, Callback callback = NULL); // For testing / automated tests. Runs a save state verification pass (async.) // Warning: callback will be called on a different thread. void Verify(Callback callback = NULL); -}; \ No newline at end of file +};