Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iR5900: Remove mid block jumping #12056

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions pcsx2/x86/iR3000A.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+

#include "iR3000A.h"
Expand Down 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
58 changes: 2 additions & 56 deletions pcsx2/x86/ix86-32/iR5900.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+

#include "Common.h"
Expand Down 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 @@ -2634,42 +2614,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
Loading