mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-11-18 01:38:08 -06:00
Merge pull request #14888 from SuperSamus/dcbx-dont-clear-icache
Jit: Don't invalidate instruction block cache with dcbx
This commit is contained in:
@@ -471,9 +471,18 @@ void Interpreter::dcbf(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
if (!ppc_state.m_enable_dcache)
|
||||
{
|
||||
// Invalidate the JIT cache here as a heuristic to compensate for
|
||||
// the lack of precise L1 icache emulation in the JIT. (Portable software
|
||||
// should use icbi consistently, but games aren't portable.)
|
||||
// Some games do not use `icbi` properly, and the JIT does not emulate the ICache accurately.
|
||||
// Therefore, we use this instruction as an heuristic for invalidating the block cache. This is
|
||||
// known to solve a crash after loading an area in games developed by Artificial Mind and
|
||||
// Movement (Monster House, Scooby-Doo! Mystery Mayhem, Scooby-Doo! Unmasked).
|
||||
// Note that this could cause unnecessary invalidation that would result in lengthy stutters. In
|
||||
// the past `dcbi` and `dcbst` invalidated the block cache as well, and games like NBA Live
|
||||
// 2005/06 or Harry Potter and the Prisoner of Azkaban are known to have suffered because of
|
||||
// that (some games like The Last Story were fixed by making `dcbst` do nothing if it was
|
||||
// preceded by `dcbt`/`dcbtst`).
|
||||
// No games are known to be negatively affected with just `dcbf`, but if some were found, then
|
||||
// this behavior would probably need to become an option.
|
||||
|
||||
interpreter.m_system.GetJitInterface().InvalidateICacheLine(address);
|
||||
return;
|
||||
}
|
||||
@@ -491,15 +500,6 @@ void Interpreter::dcbi(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
}
|
||||
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
if (!ppc_state.m_enable_dcache)
|
||||
{
|
||||
// Invalidate the JIT cache here as a heuristic to compensate for
|
||||
// the lack of precise L1 icache emulation in the JIT. (Portable software
|
||||
// should use icbi consistently, but games aren't portable.)
|
||||
interpreter.m_system.GetJitInterface().InvalidateICacheLine(address);
|
||||
return;
|
||||
}
|
||||
|
||||
interpreter.m_mmu.InvalidateDCacheLine(address);
|
||||
}
|
||||
|
||||
@@ -507,15 +507,6 @@ void Interpreter::dcbst(Interpreter& interpreter, UGeckoInstruction inst)
|
||||
{
|
||||
auto& ppc_state = interpreter.m_ppc_state;
|
||||
const u32 address = Helper_Get_EA_X(ppc_state, inst);
|
||||
if (!ppc_state.m_enable_dcache)
|
||||
{
|
||||
// Invalidate the JIT cache here as a heuristic to compensate for
|
||||
// the lack of precise L1 icache emulation in the JIT. (Portable software
|
||||
// should use icbi consistently, but games aren't portable.)
|
||||
interpreter.m_system.GetJitInterface().InvalidateICacheLine(address);
|
||||
return;
|
||||
}
|
||||
|
||||
interpreter.m_mmu.StoreDCacheLine(address);
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +253,6 @@ public:
|
||||
void negx(UGeckoInstruction inst);
|
||||
void slwx(UGeckoInstruction inst);
|
||||
void srwx(UGeckoInstruction inst);
|
||||
void dcbt(UGeckoInstruction inst);
|
||||
void dcbz(UGeckoInstruction inst);
|
||||
|
||||
void subfic(UGeckoInstruction inst);
|
||||
|
||||
@@ -199,11 +199,11 @@ constexpr std::array<Jit64OpTemplate, 107> s_table31{{
|
||||
{824, &Jit64::srawix}, // srawix
|
||||
{24, &Jit64::slwx}, // slwx
|
||||
|
||||
{54, &Jit64::dcbx}, // dcbst
|
||||
{54, &Jit64::DoNothing}, // dcbst
|
||||
{86, &Jit64::dcbx}, // dcbf
|
||||
{246, &Jit64::dcbt}, // dcbtst
|
||||
{278, &Jit64::dcbt}, // dcbt
|
||||
{470, &Jit64::dcbx}, // dcbi
|
||||
{246, &Jit64::DoNothing}, // dcbtst
|
||||
{278, &Jit64::DoNothing}, // dcbt
|
||||
{470, &Jit64::DoNothing}, // dcbi
|
||||
{758, &Jit64::DoNothing}, // dcba
|
||||
{1014, &Jit64::dcbz}, // dcbz
|
||||
|
||||
|
||||
@@ -238,6 +238,8 @@ void Jit64::dcbx(UGeckoInstruction inst)
|
||||
JITDISABLE(bJITLoadStoreOff);
|
||||
FALLBACK_IF(m_accurate_cpu_cache_enabled);
|
||||
|
||||
// See Interpreter::dcbf comment on explanation of why this exists.
|
||||
|
||||
// Check if the next instructions match a known looping pattern:
|
||||
// - dcbx rX
|
||||
// - addi rX,rX,32
|
||||
@@ -400,25 +402,6 @@ void Jit64::dcbx(UGeckoInstruction inst)
|
||||
SetJumpTarget(done);
|
||||
}
|
||||
|
||||
void Jit64::dcbt(UGeckoInstruction inst)
|
||||
{
|
||||
INSTRUCTION_START
|
||||
JITDISABLE(bJITLoadStoreOff);
|
||||
|
||||
// Prefetch. Since we don't emulate the data cache, we don't need to do anything.
|
||||
|
||||
// If a dcbst follows a dcbt, it probably isn't a case of dynamic code
|
||||
// modification, so don't bother invalidating the jit block cache.
|
||||
// This is important because invalidating the block cache when we don't
|
||||
// need to is terrible for performance.
|
||||
// (Invalidating the jit block cache on dcbst is a heuristic.)
|
||||
if (CanMergeNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 &&
|
||||
js.op[1].inst.RA == inst.RA && js.op[1].inst.RB == inst.RB)
|
||||
{
|
||||
js.skipInstructions = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Zero cache line.
|
||||
void Jit64::dcbz(UGeckoInstruction inst)
|
||||
{
|
||||
|
||||
@@ -143,7 +143,6 @@ public:
|
||||
void lmw(UGeckoInstruction inst);
|
||||
void stmw(UGeckoInstruction inst);
|
||||
void dcbx(UGeckoInstruction inst);
|
||||
void dcbt(UGeckoInstruction inst);
|
||||
void dcbz(UGeckoInstruction inst);
|
||||
void eieio(UGeckoInstruction inst);
|
||||
|
||||
|
||||
@@ -706,6 +706,8 @@ void JitArm64::dcbx(UGeckoInstruction inst)
|
||||
JITDISABLE(bJITLoadStoreOff);
|
||||
FALLBACK_IF(m_accurate_cpu_cache_enabled);
|
||||
|
||||
// See Interpreter::dcbf comment on explanation of why this invalidates the block cache.
|
||||
|
||||
u32 a = inst.RA, b = inst.RB;
|
||||
|
||||
// Check if the next instructions match a known looping pattern:
|
||||
@@ -878,25 +880,6 @@ void JitArm64::dcbx(UGeckoInstruction inst)
|
||||
gpr.Unlock(loop_counter);
|
||||
}
|
||||
|
||||
void JitArm64::dcbt(UGeckoInstruction inst)
|
||||
{
|
||||
INSTRUCTION_START
|
||||
JITDISABLE(bJITLoadStoreOff);
|
||||
|
||||
// Prefetch. Since we don't emulate the data cache, we don't need to do anything.
|
||||
|
||||
// If a dcbst follows a dcbt, it probably isn't a case of dynamic code
|
||||
// modification, so don't bother invalidating the jit block cache.
|
||||
// This is important because invalidating the block cache when we don't
|
||||
// need to is terrible for performance.
|
||||
// (Invalidating the jit block cache on dcbst is a heuristic.)
|
||||
if (CanMergeNextInstructions(1) && js.op[1].inst.OPCD == 31 && js.op[1].inst.SUBOP10 == 54 &&
|
||||
js.op[1].inst.RA == inst.RA && js.op[1].inst.RB == inst.RB)
|
||||
{
|
||||
js.skipInstructions = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void JitArm64::dcbz(UGeckoInstruction inst)
|
||||
{
|
||||
INSTRUCTION_START
|
||||
|
||||
@@ -199,11 +199,11 @@ constexpr std::array<JitArm64OpTemplate, 107> s_table31{{
|
||||
{824, &JitArm64::srawix}, // srawix
|
||||
{24, &JitArm64::slwx}, // slwx
|
||||
|
||||
{54, &JitArm64::dcbx}, // dcbst
|
||||
{54, &JitArm64::DoNothing}, // dcbst
|
||||
{86, &JitArm64::dcbx}, // dcbf
|
||||
{246, &JitArm64::dcbt}, // dcbtst
|
||||
{278, &JitArm64::dcbt}, // dcbt
|
||||
{470, &JitArm64::dcbx}, // dcbi
|
||||
{246, &JitArm64::DoNothing}, // dcbtst
|
||||
{278, &JitArm64::DoNothing}, // dcbt
|
||||
{470, &JitArm64::DoNothing}, // dcbi
|
||||
{758, &JitArm64::DoNothing}, // dcba
|
||||
{1014, &JitArm64::dcbz}, // dcbz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user