From 77d68a5aadb4bb2cbfa9cf70b901fde75d5cae57 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 28 Sep 2012 08:54:38 +1000 Subject: [PATCH] Optimized reset stack pointer when stack pointer was already mapped --- .../N64 System/Mips/Memory Virtual Mem.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 8c245eb41..053941f56 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -1266,11 +1266,22 @@ void CMipsMemoryVM::ResetMemoryStack ( void) { x86Reg Reg, TempReg; + int MipsReg = 29; CPU_Message(" ResetMemoryStack"); Reg = Get_MemoryStack(); - if (Reg != x86_Unknown) { UnMap_X86reg(Reg); } + if (Reg == x86_Unknown) + { + Reg = Map_TempReg(x86_Any, MipsReg, FALSE); + } else { + if (IsUnknown(MipsReg)) { + MoveVariableToX86reg(&_GPR[MipsReg].UW[0],CRegName::GPR_Lo[MipsReg],Reg); + } else if (IsMapped(MipsReg)) { + MoveX86RegToX86Reg(MipsRegMapLo(MipsReg),Reg); + } else { + MoveConstToX86reg(MipsRegLo(MipsReg),Reg); + } + } - Reg = Map_TempReg(x86_Any, 29, FALSE); if (bUseTlb()) { TempReg = Map_TempReg(x86_Any,-1,FALSE);