Reset RSP after calling Jit in case it cleared the code cache.

This commit is contained in:
comex
2014-09-18 18:23:36 -04:00
parent e9164247d6
commit 3df935b98e
2 changed files with 16 additions and 9 deletions

View File

@ -56,10 +56,7 @@ void Jit64AsmRoutineManager::Generate()
ABI_PopRegistersAndAdjustStack(1 << RSCRATCH, 0); ABI_PopRegistersAndAdjustStack(1 << RSCRATCH, 0);
#endif #endif
if (m_stack_top) ResetStack();
MOV(64, R(RSP), Imm64((u64)m_stack_top - 0x20));
else
MOV(64, R(RSP), M(&s_saved_rsp));
SUB(32, PPCSTATE(downcount), R(RSCRATCH)); SUB(32, PPCSTATE(downcount), R(RSCRATCH));
@ -147,6 +144,9 @@ void Jit64AsmRoutineManager::Generate()
ABI_CallFunctionA((void *)&Jit, PPCSTATE(pc)); ABI_CallFunctionA((void *)&Jit, PPCSTATE(pc));
ABI_PopRegistersAndAdjustStack(0, 0); ABI_PopRegistersAndAdjustStack(0, 0);
// Jit might have cleared the code cache
ResetStack();
JMP(dispatcherNoCheck); // no point in special casing this JMP(dispatcherNoCheck); // no point in special casing this
SetJumpTarget(bail); SetJumpTarget(bail);
@ -168,21 +168,27 @@ void Jit64AsmRoutineManager::Generate()
//Landing pad for drec space //Landing pad for drec space
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
SetJumpTarget(dbg_exit); SetJumpTarget(dbg_exit);
ResetStack();
if (m_stack_top) if (m_stack_top)
{ {
MOV(64, R(RSP), Imm64((u64)m_stack_top - 0x8)); ADD(64, R(RSP), Imm8(0x18));
POP(RSP); POP(RSP);
} }
else
{
MOV(64, R(RSP), M(&s_saved_rsp));
}
ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8, 16); ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8, 16);
RET(); RET();
GenerateCommon(); GenerateCommon();
} }
void Jit64AsmRoutineManager::ResetStack()
{
if (m_stack_top)
MOV(64, R(RSP), Imm64((u64)m_stack_top - 0x20));
else
MOV(64, R(RSP), M(&s_saved_rsp));
}
void Jit64AsmRoutineManager::GenerateCommon() void Jit64AsmRoutineManager::GenerateCommon()
{ {
fifoDirectWrite8 = AlignCode4(); fifoDirectWrite8 = AlignCode4();

View File

@ -24,6 +24,7 @@ class Jit64AsmRoutineManager : public CommonAsmRoutines
{ {
private: private:
void Generate(); void Generate();
void ResetStack();
void GenerateCommon(); void GenerateCommon();
u8* m_stack_top; u8* m_stack_top;