Core: have CRecompiler::RecompilerMain_VirtualTable handle PC as 32bit and clean up recompiler memory reset

This commit is contained in:
zilmar 2025-02-27 20:47:37 +10:30
parent 9034bc6fdc
commit 1edb5debdf
4 changed files with 14 additions and 9 deletions

View File

@ -94,7 +94,7 @@ void R4300iOp::ExecuteOps(uint32_t Cycles)
int32_t & NextTimer = *g_NextTimer;
bool CheckTimer = false;
bool updateInstructionMemory = true;
m_InstructionRegion = -1;
m_InstructionRegion = (uint64_t)-1;
while (!Done && Cycles > 0)
{

View File

@ -894,6 +894,11 @@ bool CCodeBlock::Compile()
uint32_t CCodeBlock::Finilize(CRecompMemory & RecompMem)
{
size_t codeSize = m_CodeHolder.codeSize();
if (!RecompMem.CheckRecompMem(codeSize))
{
return 0;
}
m_CompiledLocation = RecompMem.RecompPos();
m_CodeHolder.relocateToBase((uint64_t)m_CompiledLocation);
if (CDebugSettings::bRecordRecompilerAsm())
@ -914,11 +919,6 @@ uint32_t CCodeBlock::Finilize(CRecompMemory & RecompMem)
Log("====== Recompiled code ======");
m_CodeLog += CodeLog;
}
size_t codeSize = m_CodeHolder.codeSize();
if (!RecompMem.CheckRecompMem(codeSize))
{
return 0;
}
m_CodeHolder.copyFlattenedData(m_CompiledLocation, codeSize, asmjit::CopySectionFlags::kPadSectionBuffer);
m_Recompiler.RecompPos() += codeSize;

View File

@ -85,14 +85,14 @@ void CRecompiler::RecompilerMain_VirtualTable()
m_System.m_PipelineStage = PIPELINE_STAGE_NORMAL;
if (!m_MMU.ValidVaddr((uint32_t)PC))
{
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PC).c_str());
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", (uint32_t)PC).c_str());
return;
}
continue;
}
PCCompiledFunc_TABLE & table = FunctionTable()[PC >> 0xC];
uint32_t TableEntry = (PC & 0xFFF) >> 2;
PCCompiledFunc_TABLE & table = FunctionTable()[(uint32_t)PC >> 0xC];
uint32_t TableEntry = ((uint32_t)PC & 0xFFF) >> 2;
if (table)
{
CCompiledFunc * info = table[TableEntry];

View File

@ -63,6 +63,11 @@ bool CRecompMemory::CheckRecompMem(uint32_t BlockSize)
if (m_RecompSize == MaxCompileBufferSize)
{
g_Recompiler->ResetRecompCode(true);
Size = (uint32_t)((uint8_t *)m_RecompPos - (uint8_t *)m_RecompCode);
if ((Size + BlockSize) < m_RecompSize)
{
return true;
}
return false;
}
if (BlockSize > IncreaseCompileBufferSize)