irjit: Add jump crash checks.

Doesn't seem to have any significant impact on performance.
This commit is contained in:
Unknown W. Brackets 2020-07-12 22:17:36 -07:00
parent d2ef6c561c
commit 3c34c7c456
3 changed files with 6 additions and 2 deletions

View File

@ -300,9 +300,8 @@ void IRFrontend::Comp_Jump(MIPSOpcode op) {
js.cancel = true;
else
ERROR_LOG_REPORT(JIT, "Jump to invalid address: %08x", targetAddr);
js.compiling = false;
// TODO: Mark this block dirty or something? May be indication it will be changed by imports.
return;
// Continue so the block gets completed and crashes properly.
}
switch (op >> 26) {

View File

@ -224,6 +224,10 @@ void IRJit::RunLoopUntil(u64 globalticks) {
u32 data = inst & 0xFFFFFF;
IRBlock *block = blocks_.GetBlock(data);
mips_->pc = IRInterpret(mips_, block->GetInstructions(), block->GetNumInstructions());
if (!Memory::IsValidAddress(mips_->pc)) {
Core_ExecException(mips_->pc, mips_->pc, ExecExceptionType::JUMP);
break;
}
} else {
// RestoreRoundingMode(true);
Compile(mips_->pc);

View File

@ -55,6 +55,7 @@
static inline void DelayBranchTo(u32 where)
{
if (!Memory::IsValidAddress(where)) {
// TODO: What about misaligned?
Core_ExecException(where, PC, ExecExceptionType::JUMP);
}
PC += 4;