mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-06-02 19:28:11 -04:00
Merge pull request #12740 from mitaclaw/breakpoint-before-fpu-exception
Jit64/JitArm64: Check Breakpoints Before FPU Availability
This commit is contained in:
commit
50386c4e39
|
@ -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"
|
||||||
|
@ -1035,6 +1036,30 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
auto& cpu = m_system.GetCPU();
|
||||||
|
auto& power_pc = m_system.GetPowerPC();
|
||||||
|
if (m_enable_debugging && power_pc.GetBreakPoints().IsAddressBreakPoint(op.address) &&
|
||||||
|
!cpu.IsStepping())
|
||||||
|
{
|
||||||
|
gpr.Flush();
|
||||||
|
fpr.Flush();
|
||||||
|
|
||||||
|
MOV(32, PPCSTATE(pc), Imm32(op.address));
|
||||||
|
ABI_PushRegistersAndAdjustStack({}, 0);
|
||||||
|
ABI_CallFunctionP(PowerPC::CheckBreakPointsFromJIT, &power_pc);
|
||||||
|
ABI_PopRegistersAndAdjustStack({}, 0);
|
||||||
|
MOV(64, R(RSCRATCH), ImmPtr(cpu.GetStatePtr()));
|
||||||
|
CMP(32, MatR(RSCRATCH), Imm32(Common::ToUnderlying(CPU::State::Running)));
|
||||||
|
FixupBranch noBreakpoint = J_CC(CC_E);
|
||||||
|
|
||||||
|
Cleanup();
|
||||||
|
MOV(32, PPCSTATE(npc), Imm32(op.address));
|
||||||
|
SUB(32, PPCSTATE(downcount), Imm32(js.downcountAmount));
|
||||||
|
JMP(asm_routines.dispatcher_exit, Jump::Near);
|
||||||
|
|
||||||
|
SetJumpTarget(noBreakpoint);
|
||||||
|
}
|
||||||
|
|
||||||
if ((opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound)
|
if ((opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound)
|
||||||
{
|
{
|
||||||
// This instruction uses FPU - needs to add FP exception bailout
|
// This instruction uses FPU - needs to add FP exception bailout
|
||||||
|
@ -1061,30 +1086,6 @@ bool Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
|
||||||
js.firstFPInstructionFound = true;
|
js.firstFPInstructionFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& cpu = m_system.GetCPU();
|
|
||||||
auto& power_pc = m_system.GetPowerPC();
|
|
||||||
if (m_enable_debugging && power_pc.GetBreakPoints().IsAddressBreakPoint(op.address) &&
|
|
||||||
!cpu.IsStepping())
|
|
||||||
{
|
|
||||||
gpr.Flush();
|
|
||||||
fpr.Flush();
|
|
||||||
|
|
||||||
MOV(32, PPCSTATE(pc), Imm32(op.address));
|
|
||||||
ABI_PushRegistersAndAdjustStack({}, 0);
|
|
||||||
ABI_CallFunctionP(PowerPC::CheckBreakPointsFromJIT, &power_pc);
|
|
||||||
ABI_PopRegistersAndAdjustStack({}, 0);
|
|
||||||
MOV(64, R(RSCRATCH), ImmPtr(cpu.GetStatePtr()));
|
|
||||||
TEST(32, MatR(RSCRATCH), Imm32(0xFFFFFFFF));
|
|
||||||
FixupBranch noBreakpoint = J_CC(CC_Z);
|
|
||||||
|
|
||||||
Cleanup();
|
|
||||||
MOV(32, PPCSTATE(npc), Imm32(op.address));
|
|
||||||
SUB(32, PPCSTATE(downcount), Imm32(js.downcountAmount));
|
|
||||||
JMP(asm_routines.dispatcher_exit, Jump::Near);
|
|
||||||
|
|
||||||
SetJumpTarget(noBreakpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bJITRegisterCacheOff)
|
if (bJITRegisterCacheOff)
|
||||||
{
|
{
|
||||||
gpr.Flush();
|
gpr.Flush();
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -8,6 +8,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"
|
||||||
|
@ -1239,6 +1240,37 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (m_enable_debugging && !cpu.IsStepping() &&
|
||||||
|
m_system.GetPowerPC().GetBreakPoints().IsAddressBreakPoint(op.address))
|
||||||
|
{
|
||||||
|
FlushCarry();
|
||||||
|
gpr.Flush(FlushMode::All, ARM64Reg::INVALID_REG);
|
||||||
|
fpr.Flush(FlushMode::All, ARM64Reg::INVALID_REG);
|
||||||
|
|
||||||
|
static_assert(PPCSTATE_OFF(pc) <= 252);
|
||||||
|
static_assert(PPCSTATE_OFF(pc) + 4 == PPCSTATE_OFF(npc));
|
||||||
|
|
||||||
|
MOVI2R(DISPATCHER_PC, op.address);
|
||||||
|
STP(IndexType::Signed, DISPATCHER_PC, DISPATCHER_PC, PPC_REG, PPCSTATE_OFF(pc));
|
||||||
|
ABI_CallFunction(&PowerPC::CheckBreakPointsFromJIT, &m_system.GetPowerPC());
|
||||||
|
|
||||||
|
LDR(IndexType::Unsigned, ARM64Reg::W0, ARM64Reg::X0,
|
||||||
|
MOVPage2R(ARM64Reg::X0, cpu.GetStatePtr()));
|
||||||
|
static_assert(Common::ToUnderlying(CPU::State::Running) == 0);
|
||||||
|
FixupBranch no_breakpoint = CBZ(ARM64Reg::W0);
|
||||||
|
|
||||||
|
Cleanup();
|
||||||
|
if (IsProfilingEnabled())
|
||||||
|
{
|
||||||
|
ABI_CallFunction(&JitBlock::ProfileData::EndProfiling, b->profile_data.get(),
|
||||||
|
js.downcountAmount);
|
||||||
|
}
|
||||||
|
DoDownCount();
|
||||||
|
B(dispatcher_exit);
|
||||||
|
|
||||||
|
SetJumpTarget(no_breakpoint);
|
||||||
|
}
|
||||||
|
|
||||||
if ((opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound)
|
if ((opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound)
|
||||||
{
|
{
|
||||||
// This instruction uses FPU - needs to add FP exception bailout
|
// This instruction uses FPU - needs to add FP exception bailout
|
||||||
|
@ -1268,36 +1300,6 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
|
||||||
js.firstFPInstructionFound = true;
|
js.firstFPInstructionFound = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_enable_debugging && !cpu.IsStepping() &&
|
|
||||||
m_system.GetPowerPC().GetBreakPoints().IsAddressBreakPoint(op.address))
|
|
||||||
{
|
|
||||||
FlushCarry();
|
|
||||||
gpr.Flush(FlushMode::All, ARM64Reg::INVALID_REG);
|
|
||||||
fpr.Flush(FlushMode::All, ARM64Reg::INVALID_REG);
|
|
||||||
|
|
||||||
static_assert(PPCSTATE_OFF(pc) <= 252);
|
|
||||||
static_assert(PPCSTATE_OFF(pc) + 4 == PPCSTATE_OFF(npc));
|
|
||||||
|
|
||||||
MOVI2R(DISPATCHER_PC, op.address);
|
|
||||||
STP(IndexType::Signed, DISPATCHER_PC, DISPATCHER_PC, PPC_REG, PPCSTATE_OFF(pc));
|
|
||||||
ABI_CallFunction(&PowerPC::CheckBreakPointsFromJIT, &m_system.GetPowerPC());
|
|
||||||
|
|
||||||
LDR(IndexType::Unsigned, ARM64Reg::W0, ARM64Reg::X0,
|
|
||||||
MOVPage2R(ARM64Reg::X0, cpu.GetStatePtr()));
|
|
||||||
FixupBranch no_breakpoint = CBZ(ARM64Reg::W0);
|
|
||||||
|
|
||||||
Cleanup();
|
|
||||||
if (IsProfilingEnabled())
|
|
||||||
{
|
|
||||||
ABI_CallFunction(&JitBlock::ProfileData::EndProfiling, b->profile_data.get(),
|
|
||||||
js.downcountAmount);
|
|
||||||
}
|
|
||||||
DoDownCount();
|
|
||||||
B(dispatcher_exit);
|
|
||||||
|
|
||||||
SetJumpTarget(no_breakpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bJITRegisterCacheOff)
|
if (bJITRegisterCacheOff)
|
||||||
{
|
{
|
||||||
FlushCarry();
|
FlushCarry();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "Common/Arm64Emitter.h"
|
#include "Common/Arm64Emitter.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);
|
||||||
|
|
Loading…
Reference in a new issue