jit-ir: Clear emuhacks on block destroy.

This commit is contained in:
Unknown W. Brackets 2016-05-14 08:40:53 -07:00
parent 51bcb02921
commit b74df87db0
2 changed files with 15 additions and 0 deletions

View File

@ -149,6 +149,9 @@ bool IRJit::ReplaceJalTo(u32 dest) {
} }
void IRBlockCache::Clear() { void IRBlockCache::Clear() {
for (size_t i = 0; i < blocks_.size(); ++i) {
blocks_[i].Destroy(i);
}
blocks_.clear(); blocks_.clear();
} }
@ -162,6 +165,17 @@ void IRBlock::Finalize(int number) {
Memory::Write_Opcode_JIT(origAddr_, opcode); Memory::Write_Opcode_JIT(origAddr_, opcode);
} }
void IRBlock::Destroy(int number) {
if (origAddr_) {
MIPSOpcode opcode = MIPSOpcode(MIPS_EMUHACK_OPCODE | number);
if (Memory::ReadUnchecked_U32(origAddr_) == opcode.encoding)
Memory::Write_Opcode_JIT(origAddr_, origFirstOpcode_);
// Let's mark this invalid so we don't try to clear it again.
origAddr_ = 0;
}
}
MIPSOpcode IRJit::GetOriginalOp(MIPSOpcode op) { MIPSOpcode IRJit::GetOriginalOp(MIPSOpcode op) {
IRBlock *b = blocks_.GetBlock(op.encoding & 0xFFFFFF); IRBlock *b = blocks_.GetBlock(op.encoding & 0xFFFFFF);
return b->GetOriginalFirstOp(); return b->GetOriginalFirstOp();

View File

@ -99,6 +99,7 @@ public:
MIPSOpcode GetOriginalFirstOp() const { return origFirstOpcode_; } MIPSOpcode GetOriginalFirstOp() const { return origFirstOpcode_; }
void Finalize(int number); void Finalize(int number);
void Destroy(int number);
private: private:
IRInst *instr_; IRInst *instr_;