Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11170 from JosJuice/jit64-dispatcher-no-check
Jit64: Add dispatcher_no_timing_check jump target
  • Loading branch information
JMC47 committed Oct 22, 2022
2 parents 55d269c + 09f9a58 commit b7310a1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
8 changes: 2 additions & 6 deletions Source/Core/Core/PowerPC/Jit64/Jit.cpp
Expand Up @@ -598,10 +598,6 @@ void Jit64::JustWriteExit(u32 destination, bool bl, u32 after)

MOV(32, PPCSTATE(pc), Imm32(destination));

// Do not skip breakpoint check if debugging.
const u8* dispatcher =
m_enable_debugging ? asm_routines.dispatcher : asm_routines.dispatcher_no_check;

// Perform downcount flag check, followed by the requested exit
if (bl)
{
Expand All @@ -613,7 +609,7 @@ void Jit64::JustWriteExit(u32 destination, bool bl, u32 after)
SwitchToNearCode();

linkData.exitPtrs = GetWritableCodePtr();
CALL(dispatcher);
CALL(asm_routines.dispatcher_no_timing_check);

SetJumpTarget(after_fixup);
POP(RSCRATCH);
Expand All @@ -624,7 +620,7 @@ void Jit64::JustWriteExit(u32 destination, bool bl, u32 after)
J_CC(CC_LE, asm_routines.do_timing);

linkData.exitPtrs = GetWritableCodePtr();
JMP(dispatcher, true);
JMP(asm_routines.dispatcher_no_timing_check, true);
}

b->linkData.push_back(linkData);
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/Core/PowerPC/Jit64/JitAsm.cpp
Expand Up @@ -83,12 +83,14 @@ void Jit64AsmRoutineManager::Generate()
SUB(32, PPCSTATE(downcount), R(RSCRATCH2));

dispatcher = GetCodePtr();

// Expected result of SUB(32, PPCSTATE(downcount), Imm32(block_cycles)) is in RFLAGS.
// Branch if downcount is <= 0 (signed).
FixupBranch bail = J_CC(CC_LE, true);

FixupBranch dbg_exit;
dispatcher_no_timing_check = GetCodePtr();

FixupBranch dbg_exit;
if (enable_debugging)
{
MOV(64, R(RSCRATCH), ImmPtr(CPU::GetStatePtr()));
Expand Down
7 changes: 2 additions & 5 deletions Source/Core/Core/PowerPC/Jit64Common/BlockCache.cpp
Expand Up @@ -13,12 +13,9 @@ JitBlockCache::JitBlockCache(JitBase& jit) : JitBaseBlockCache{jit}

void JitBlockCache::WriteLinkBlock(const JitBlock::LinkData& source, const JitBlock* dest)
{
// Do not skip breakpoint check if debugging.
const u8* dispatcher = m_jit.IsDebuggingEnabled() ? m_jit.GetAsmRoutines()->dispatcher :
m_jit.GetAsmRoutines()->dispatcher_no_check;

u8* location = source.exitPtrs;
const u8* address = dest ? dest->checkedEntry : dispatcher;
const u8* address =
dest ? dest->checkedEntry : m_jit.GetAsmRoutines()->dispatcher_no_timing_check;
if (source.call)
{
Gen::XEmitter emit(location, location + 5);
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp
Expand Up @@ -84,6 +84,7 @@ void JitArm64::GenerateAsm()
// The result of slice decrementation should be in flags if somebody jumped here
FixupBranch bail = B(CC_LE);

dispatcher_no_timing_check = GetCodePtr();
dispatcher_no_check = GetCodePtr();

bool assembly_dispatcher = true;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/PowerPC/JitCommon/JitAsmCommon.h
Expand Up @@ -17,6 +17,7 @@ struct CommonAsmRoutinesBase

const u8* dispatcher_mispredicted_blr;
const u8* dispatcher;
const u8* dispatcher_no_timing_check;
const u8* dispatcher_no_check;

const u8* do_timing;
Expand Down

0 comments on commit b7310a1

Please sign in to comment.