Skip to content

Commit

Permalink
Core: Have CX86RegInfo::Map_TempReg generate a BreakPoint if it mappi…
Browse files Browse the repository at this point in the history
…ng a protected register
  • Loading branch information
project64 committed Feb 22, 2024
1 parent e082cd5 commit fae0b81
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Source/Project64-core/N64System/Recompiler/x86/x86RegInfo.cpp
Expand Up @@ -1215,8 +1215,33 @@ asmjit::x86::Gp CX86RegInfo::Map_TempReg(asmjit::x86::Gp Reg, int32_t MipsReg, b
}
else if (GetX86Mapped(GetIndexFromX86Reg(Reg)) == Stack_Mapped)
{
if (GetX86Protected(GetIndexFromX86Reg(Reg)))
{
WriteTrace(TraceRegisterCache, TraceError, "Register is protected");
g_Notify->BreakPoint(__FILE__, __LINE__);
return x86Reg_Unknown;
}
UnMap_X86reg(Reg);
}
else if (GetX86Mapped(GetIndexFromX86Reg(Reg)) == NotMapped)
{
if (GetX86Protected(GetIndexFromX86Reg(Reg)))
{
WriteTrace(TraceRegisterCache, TraceError, "Register is protected");
g_Notify->BreakPoint(__FILE__, __LINE__);
return x86Reg_Unknown;
}
}
else if (GetX86Mapped(GetIndexFromX86Reg(Reg)) == Temp_Mapped)
{
//Already mapped as temporary register
}
else
{
WriteTrace(TraceRegisterCache, TraceError, "Failed to map temp reg to %s", CX86Ops::x86_Name(Reg));
g_Notify->BreakPoint(__FILE__, __LINE__);
return x86Reg_Unknown;
}
m_CodeBlock.Log(" regcache: allocate %s as temp storage", CX86Ops::x86_Name(Reg));

if (MipsReg >= 0)
Expand Down Expand Up @@ -1782,6 +1807,7 @@ bool CX86RegInfo::UnMap_X86reg(const asmjit::x86::Gp & Reg)
{
m_CodeBlock.Log(" regcache: unallocate %s from temp storage", CX86Ops::x86_Name(Reg));
SetX86Mapped(RegIndex, NotMapped);
SetX86Protected(RegIndex, false);
return true;
}
}
Expand All @@ -1790,13 +1816,15 @@ bool CX86RegInfo::UnMap_X86reg(const asmjit::x86::Gp & Reg)
m_CodeBlock.Log(" regcache: unallocate %s from memory stack", CX86Ops::x86_Name(Reg));
m_Assembler.MoveX86regToVariable(&(g_Recompiler->MemoryStackPos()), "MemoryStack", Reg);
SetX86Mapped(RegIndex, NotMapped);
SetX86Protected(RegIndex, false);
return true;
}
else if (GetX86Mapped(RegIndex) == CX86RegInfo::FPStatusReg_Mapped)
{
m_CodeBlock.Log(" regcache: unallocate %s from FP Status Reg", CX86Ops::x86_Name(Reg));
m_Assembler.MoveX86regToVariable(&g_Reg->m_FPCR[31], "FPCR[31]", Reg);
SetX86Mapped(RegIndex, NotMapped);
SetX86Protected(RegIndex, false);
return true;
}
else
Expand Down

0 comments on commit fae0b81

Please sign in to comment.