From b4740a2bcabff724454776c99a12ea1a2ff3060b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Tue, 14 Mar 2017 12:32:20 +0100 Subject: [PATCH] Fix bug where dispatcher would not check core state directly after Advance. Fixes #9398 properly (it was previously hidden somehow with extra backbuffer binds). --- Core/MIPS/ARM/ArmAsm.cpp | 5 +++-- Core/MIPS/ARM64/Arm64Asm.cpp | 5 +++-- Core/MIPS/x86/Asm.cpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Core/MIPS/ARM/ArmAsm.cpp b/Core/MIPS/ARM/ArmAsm.cpp index 2ee8b1f434..e657bad925 100644 --- a/Core/MIPS/ARM/ArmAsm.cpp +++ b/Core/MIPS/ARM/ArmAsm.cpp @@ -177,7 +177,7 @@ void ArmJit::GenerateFixedCode() { QuickCallFunction(R0, &CoreTiming::Advance); ApplyRoundingMode(true); RestoreDowncount(); - FixupBranch skipToRealDispatch = B(); //skip the sync and compare first time + FixupBranch skipToCoreStateCheck = B(); //skip the downcount check dispatcherCheckCoreState = GetCodePtr(); @@ -185,6 +185,8 @@ void ArmJit::GenerateFixedCode() { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bailCoreState = B_CC(CC_MI); + SetJumpTarget(skipToCoreStateCheck); + MOVI2R(R0, (u32)(uintptr_t)&coreState); LDR(R0, R0); CMP(R0, 0); @@ -202,7 +204,6 @@ void ArmJit::GenerateFixedCode() { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bail = B_CC(CC_MI); - SetJumpTarget(skipToRealDispatch); SetJumpTarget(skipToRealDispatch2); dispatcherNoCheck = GetCodePtr(); diff --git a/Core/MIPS/ARM64/Arm64Asm.cpp b/Core/MIPS/ARM64/Arm64Asm.cpp index 836a869ea6..4a37a8da22 100644 --- a/Core/MIPS/ARM64/Arm64Asm.cpp +++ b/Core/MIPS/ARM64/Arm64Asm.cpp @@ -217,7 +217,7 @@ void Arm64Jit::GenerateFixedCode(const JitOptions &jo) { QuickCallFunction(SCRATCH1_64, &CoreTiming::Advance); ApplyRoundingMode(true); LoadStaticRegisters(); - FixupBranch skipToRealDispatch = B(); //skip the sync and compare first time + FixupBranch skipToCoreStateCheck = B(); //skip the downcount check dispatcherCheckCoreState = GetCodePtr(); @@ -225,6 +225,8 @@ void Arm64Jit::GenerateFixedCode(const JitOptions &jo) { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bailCoreState = B(CC_MI); + SetJumpTarget(skipToCoreStateCheck); + MOVP2R(SCRATCH1_64, &coreState); LDR(INDEX_UNSIGNED, SCRATCH1, SCRATCH1_64, 0); CMP(SCRATCH1, 0); @@ -242,7 +244,6 @@ void Arm64Jit::GenerateFixedCode(const JitOptions &jo) { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bail = B(CC_MI); - SetJumpTarget(skipToRealDispatch); SetJumpTarget(skipToRealDispatch2); dispatcherNoCheck = GetCodePtr(); diff --git a/Core/MIPS/x86/Asm.cpp b/Core/MIPS/x86/Asm.cpp index f98b38dca6..e0134518b3 100644 --- a/Core/MIPS/x86/Asm.cpp +++ b/Core/MIPS/x86/Asm.cpp @@ -144,7 +144,7 @@ void Jit::GenerateFixedCode(JitOptions &jo) { RestoreRoundingMode(true); ABI_CallFunction(reinterpret_cast(&CoreTiming::Advance)); ApplyRoundingMode(true); - FixupBranch skipToRealDispatch = J(); //skip the sync and compare first time + FixupBranch skipToCoreStateCheck = J(); //skip the downcount check dispatcherCheckCoreState = GetCodePtr(); @@ -152,6 +152,7 @@ void Jit::GenerateFixedCode(JitOptions &jo) { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bailCoreState = J_CC(CC_S, true); + SetJumpTarget(skipToCoreStateCheck); CMP(32, M(&coreState), Imm32(0)); FixupBranch badCoreState = J_CC(CC_NZ, true); FixupBranch skipToRealDispatch2 = J(); //skip the sync and compare first time @@ -162,7 +163,6 @@ void Jit::GenerateFixedCode(JitOptions &jo) { // IMPORTANT - We jump on negative, not carry!!! FixupBranch bail = J_CC(CC_S, true); - SetJumpTarget(skipToRealDispatch); SetJumpTarget(skipToRealDispatch2); dispatcherNoCheck = GetCodePtr();