Skip to content

Commit

Permalink
iR5900: Remove mid block jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanTheToaster committed Dec 24, 2024
1 parent a34467d commit 2098763
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 78 deletions.
23 changes: 0 additions & 23 deletions pcsx2/x86/iR3000A.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ static void iopRecRecompile(u32 startpc);
static const void* iopDispatcherEvent = nullptr;
static const void* iopDispatcherReg = nullptr;
static const void* iopJITCompile = nullptr;
static const void* iopJITCompileInBlock = nullptr;
static const void* iopEnterRecompiledCode = nullptr;
static const void* iopExitRecompiledCode = nullptr;

Expand Down Expand Up @@ -183,13 +182,6 @@ static const void* _DynGen_JITCompile()
return retval;
}

static const void* _DynGen_JITCompileInBlock()
{
u8* retval = xGetPtr();
xJMP((void*)iopJITCompile);
return retval;
}

// called when jumping to variable pc address
static const void* _DynGen_DispatcherReg()
{
Expand Down Expand Up @@ -244,7 +236,6 @@ static void _DynGen_Dispatchers()
iopDispatcherReg = _DynGen_DispatcherReg();

iopJITCompile = _DynGen_JITCompile();
iopJITCompileInBlock = _DynGen_JITCompileInBlock();
iopEnterRecompiledCode = _DynGen_EnterRecompiledCode();

recBlocks.SetJITCompile(iopJITCompile);
Expand Down Expand Up @@ -1606,14 +1597,6 @@ static void iopRecRecompile(const u32 startpc)

while (1)
{
BASEBLOCK* pblock = PSX_GETBLOCK(i);
if (i != startpc && pblock->GetFnptr() != (uptr)iopJITCompile && pblock->GetFnptr() != (uptr)iopJITCompileInBlock)
{
// branch = 3
willbranch3 = 1;
s_nEndBlock = i;
break;
}

psxRegs.code = iopMemRead32(i);

Expand Down Expand Up @@ -1716,12 +1699,6 @@ static void iopRecRecompile(const u32 startpc)
pxAssert((psxpc - startpc) >> 2 <= 0xffff);
s_pCurBlockEx->size = (psxpc - startpc) >> 2;

for (i = 1; i < (u32)s_pCurBlockEx->size; ++i)
{
if (s_pCurBlock[i].GetFnptr() == (uptr)iopJITCompile)
s_pCurBlock[i].SetFnptr((uptr)iopJITCompileInBlock);
}

if (!(psxpc & 0x10000000))
g_psxMaxRecMem = std::max((psxpc & ~0xa0000000), g_psxMaxRecMem);

Expand Down
57 changes: 2 additions & 55 deletions pcsx2/x86/ix86-32/iR5900.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ static void dyna_page_reset(u32 start, u32 sz);
static const void* DispatcherEvent = nullptr;
static const void* DispatcherReg = nullptr;
static const void* JITCompile = nullptr;
static const void* JITCompileInBlock = nullptr;
static const void* EnterRecompiledCode = nullptr;
static const void* DispatchBlockDiscard = nullptr;
static const void* DispatchPageReset = nullptr;
Expand Down Expand Up @@ -389,13 +388,6 @@ static const void* _DynGen_JITCompile()
return retval;
}

static const void* _DynGen_JITCompileInBlock()
{
u8* retval = xGetAlignedCallTarget();
xJMP(JITCompile);
return retval;
}

// called when jumping to variable pc address
static const void* _DynGen_DispatcherReg()
{
Expand Down Expand Up @@ -479,7 +471,6 @@ static void _DynGen_Dispatchers()
DispatcherReg = _DynGen_DispatcherReg();

JITCompile = _DynGen_JITCompile();
JITCompileInBlock = _DynGen_JITCompileInBlock();
EnterRecompiledCode = _DynGen_EnterRecompiledCode();
DispatchBlockDiscard = _DynGen_DispatchBlockDiscard();
DispatchPageReset = _DynGen_DispatchPageReset();
Expand Down Expand Up @@ -773,9 +764,7 @@ void recClear(u32 addr, u32 size)

lowerextent = std::min(lowerextent, blockstart);
upperextent = std::max(upperextent, blockend);
// This might end up inside a block that doesn't contain the clearing range,
// so set it to recompile now. This will become JITCompile if we clear it.
pblock->SetFnptr((uptr)JITCompileInBlock);
pblock->SetFnptr((uptr)JITCompile);

blockidx--;
}
Expand Down Expand Up @@ -2305,8 +2294,6 @@ static void recRecompile(const u32 startpc)

while (1)
{
BASEBLOCK* pblock = PC_GETBLOCK(i);

// stop before breakpoints
if (isBreakpointNeeded(i) != 0 || isMemcheckNeeded(i) != 0)
{
Expand All @@ -2324,13 +2311,6 @@ static void recRecompile(const u32 startpc)
eeRecPerfLog.Write("Pagesplit @ %08X : size=%d insts", startpc, (i - startpc) / 4);
break;
}

if (pblock->GetFnptr() != (uptr)JITCompile && pblock->GetFnptr() != (uptr)JITCompileInBlock)
{
willbranch3 = 1;
s_nEndBlock = i;
break;
}
}

//HUH ? PSM ? whut ? THIS IS VIRTUAL ACCESS GOD DAMMIT
Expand Down Expand Up @@ -2566,6 +2546,7 @@ static void recRecompile(const u32 startpc)
if (EmuConfig.Speedhacks.vuFlagHack)
COP2FlagHackPass().Run(startpc, s_nEndBlock, s_pInstCache + 1);
}
//WARNING_LOG("Compiling block {:08X} => {:08X}", startpc, s_nEndBlock);

#ifdef DUMP_BLOCKS
ZydisDecoder disas_decoder;
Expand Down Expand Up @@ -2634,42 +2615,8 @@ static void recRecompile(const u32 startpc)
pxAssert((pc - startpc) >> 2 <= 0xffff);
s_pCurBlockEx->size = (pc - startpc) >> 2;

if (HWADDR(pc) <= Ps2MemSize::ExposedRam)
{
BASEBLOCKEX* oldBlock;
int i;

i = recBlocks.LastIndex(HWADDR(pc) - 4);
while ((oldBlock = recBlocks[i--]))
{
if (oldBlock == s_pCurBlockEx)
continue;
if (oldBlock->startpc >= HWADDR(pc))
continue;
if ((oldBlock->startpc + oldBlock->size * 4) <= HWADDR(startpc))
break;

if (memcmp(&recRAMCopy[oldBlock->startpc / 4], PSM(oldBlock->startpc),
oldBlock->size * 4))
{
recClear(startpc, (pc - startpc) / 4);
s_pCurBlockEx = recBlocks.Get(HWADDR(startpc));
pxAssert(s_pCurBlockEx->startpc == HWADDR(startpc));
break;
}
}

memcpy(&recRAMCopy[HWADDR(startpc) / 4], PSM(startpc), pc - startpc);
}

s_pCurBlock->SetFnptr((uptr)recPtr);

for (i = 1; i < static_cast<u32>(s_pCurBlockEx->size); i++)
{
if ((uptr)JITCompile == s_pCurBlock[i].GetFnptr())
s_pCurBlock[i].SetFnptr((uptr)JITCompileInBlock);
}

if (!(pc & 0x10000000))
maxrecmem = std::max((pc & ~0xa0000000), maxrecmem);

Expand Down

0 comments on commit 2098763

Please sign in to comment.