SaveState: Restore replacements in only one place.

This commit is contained in:
Unknown W. Brackets 2022-10-29 17:56:47 -07:00
parent 0a98ac43fa
commit 17d94cd358
3 changed files with 8 additions and 3 deletions

View file

@ -1652,7 +1652,8 @@ std::map<u32, u32> SaveAndClearReplacements() {
std::map<u32, u32> saved;
for (auto it = replacedInstructions.begin(), end = replacedInstructions.end(); it != end; ++it) {
const u32 addr = it->first;
const u32 curInstr = Memory::Read_U32(addr);
// This will not retain jit blocks.
const u32 curInstr = Memory::Read_Opcode_JIT(addr).encoding;
if (MIPS_IS_REPLACEMENT(curInstr)) {
saved[addr] = curInstr;
Memory::Write_U32(it->second, addr);

View file

@ -591,7 +591,7 @@ void Jit::Comp_ReplacementFunc(MIPSOpcode op) {
// Not sure about the cause.
Memory::Opcode origInstruction = Memory::Read_Instruction(GetCompilerPC(), true);
if (origInstruction.encoding == op.encoding) {
ERROR_LOG(HLE, "Replacement broken (savestate problem?): %08x", op.encoding);
ERROR_LOG(HLE, "Replacement broken (savestate problem?): %08x at %08x", op.encoding, GetCompilerPC());
return;
}

View file

@ -316,7 +316,11 @@ namespace SaveState
} else {
Memory::DoState(p);
}
RestoreSavedReplacements(savedReplacements);
// Don't bother restoring if reading, we'll deal with that in KernelModuleDoState.
// In theory, different functions might have been runtime loaded in the state.
if (p.mode != p.MODE_READ)
RestoreSavedReplacements(savedReplacements);
MemoryStick_DoState(p);
currentMIPS->DoState(p);