Jit64: Smaller Instruction Breakpoint Condition

Also some static_asserts in JitArm64.
This commit is contained in:
mitaclaw 2024-04-28 15:54:15 -07:00
parent 307a1e3ab8
commit 756ea81ab2
4 changed files with 13 additions and 6 deletions

View File

@ -16,6 +16,7 @@
#endif #endif
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/EnumUtils.h"
#include "Common/GekkoDisassembler.h" #include "Common/GekkoDisassembler.h"
#include "Common/IOFile.h" #include "Common/IOFile.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
@ -1048,8 +1049,8 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
ABI_CallFunctionP(PowerPC::CheckBreakPointsFromJIT, &power_pc); ABI_CallFunctionP(PowerPC::CheckBreakPointsFromJIT, &power_pc);
ABI_PopRegistersAndAdjustStack({}, 0); ABI_PopRegistersAndAdjustStack({}, 0);
MOV(64, R(RSCRATCH), ImmPtr(cpu.GetStatePtr())); MOV(64, R(RSCRATCH), ImmPtr(cpu.GetStatePtr()));
TEST(32, MatR(RSCRATCH), Imm32(0xFFFFFFFF)); CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running)));
FixupBranch noBreakpoint = J_CC(CC_Z); FixupBranch noBreakpoint = J_CC(CC_E);
Cleanup(); Cleanup();
MOV(32, PPCSTATE(npc), Imm32(op.address)); MOV(32, PPCSTATE(npc), Imm32(op.address));

View File

@ -6,6 +6,7 @@
#include <climits> #include <climits>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/EnumUtils.h"
#include "Common/JitRegister.h" #include "Common/JitRegister.h"
#include "Common/x64ABI.h" #include "Common/x64ABI.h"
#include "Common/x64Emitter.h" #include "Common/x64Emitter.h"
@ -105,8 +106,8 @@ void Jit64AsmRoutineManager::Generate()
if (enable_debugging) if (enable_debugging)
{ {
MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr())); MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr()));
TEST(32, MatR(RSCRATCH), Imm32(0xFFFFFFFF)); CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running)));
dbg_exit = J_CC(CC_NZ, Jump::Near); dbg_exit = J_CC(CC_NE, Jump::Near);
} }
SetJumpTarget(skipToRealDispatch); SetJumpTarget(skipToRealDispatch);
@ -236,8 +237,8 @@ void Jit64AsmRoutineManager::Generate()
// Check the state pointer to see if we are exiting // Check the state pointer to see if we are exiting
// Gets checked on at the end of every slice // Gets checked on at the end of every slice
MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr())); MOV(64, R(RSCRATCH), ImmPtr(system.GetCPU().GetStatePtr()));
TEST(32, MatR(RSCRATCH), Imm32(0xFFFFFFFF)); CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running)));
J_CC(CC_Z, outerLoop); J_CC(CC_E, outerLoop);
// Landing pad for drec space // Landing pad for drec space
dispatcher_exit = GetCodePtr(); dispatcher_exit = GetCodePtr();

View File

@ -7,6 +7,7 @@
#include "Common/Arm64Emitter.h" #include "Common/Arm64Emitter.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/EnumUtils.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
@ -1185,6 +1186,7 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
LDR(IndexType::Unsigned, ARM64Reg::W0, ARM64Reg::X0, LDR(IndexType::Unsigned, ARM64Reg::W0, ARM64Reg::X0,
MOVPage2R(ARM64Reg::X0, cpu.GetStatePtr())); MOVPage2R(ARM64Reg::X0, cpu.GetStatePtr()));
static_assert(Common::ToUnderlying(CPU::State::Running) == 0);
FixupBranch no_breakpoint = CBZ(ARM64Reg::W0); FixupBranch no_breakpoint = CBZ(ARM64Reg::W0);
Cleanup(); Cleanup();

View File

@ -9,6 +9,7 @@
#include "Common/BitUtils.h" #include "Common/BitUtils.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
#include "Common/EnumUtils.h"
#include "Common/FloatUtils.h" #include "Common/FloatUtils.h"
#include "Common/JitRegister.h" #include "Common/JitRegister.h"
#include "Common/MathUtil.h" #include "Common/MathUtil.h"
@ -88,6 +89,7 @@ void JitArm64::GenerateAsm()
{ {
LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8, LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8,
MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr())); MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr()));
static_assert(Common::ToUnderlying(CPU::State::Running) == 0);
debug_exit = CBNZ(ARM64Reg::W8); debug_exit = CBNZ(ARM64Reg::W8);
} }
@ -195,6 +197,7 @@ void JitArm64::GenerateAsm()
// Check the state pointer to see if we are exiting // Check the state pointer to see if we are exiting
// Gets checked on at the end of every slice // Gets checked on at the end of every slice
LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8, MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr())); LDR(IndexType::Unsigned, ARM64Reg::W8, ARM64Reg::X8, MOVPage2R(ARM64Reg::X8, cpu.GetStatePtr()));
static_assert(Common::ToUnderlying(CPU::State::Running) == 0);
FixupBranch exit = CBNZ(ARM64Reg::W8); FixupBranch exit = CBNZ(ARM64Reg::W8);
SetJumpTarget(to_start_of_timing_slice); SetJumpTarget(to_start_of_timing_slice);