Skip to content

Commit 047f0c2

Browse files
committed
Fixing dynarec.
1 parent ed2f63e commit 047f0c2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/core/DynaRec_aa64/recompiler.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ void DynaRecCPU::emitDispatcher() {
169169
gen.Str(contextPointer,
170170
MemOperand(sp, -16, PreIndex)); // Save contextPointer register in stack (also align stack pointer)
171171

172-
gen.Mov(runningPointer, (uintptr_t)PCSX::g_system->runningPtr()); // Move runningPtr to runningPointer register
173172
gen.Mov(contextPointer, (uintptr_t)this); // Load context pointer
174173

175174
// Back up all our allocateable volatile regs
@@ -188,8 +187,12 @@ void DynaRecCPU::emitDispatcher() {
188187

189188
loadThisPointer(arg1.X()); // Poll events
190189
call(recBranchTestWrapper);
190+
gen.Mov(runningPointer, (uintptr_t)PCSX::g_system->runningPtr()); // Move runningPtr to runningPointer register
191191
gen.Ldrb(w0, MemOperand(runningPointer)); // Check if PCSX::g_system->running is true
192192
gen.Cbz(w0, &done); // If it's not, return
193+
gen.Mov(runningPointer, (uintptr_t)PCSX::g_system->quittingPtr()); // Load pointer to "quitting" variable
194+
gen.Ldrb(w0, MemOperand(runningPointer)); // Check if PCSX::g_system->quitting is true
195+
gen.Cbnz(w0, &done); // If it is, return
193196
emitBlockLookup(); // Otherwise, look up next block
194197

195198
gen.align();

src/core/DynaRec_x64/recompiler.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ void DynaRecCPU::emitDispatcher() {
186186
gen.push(reg.cvt64());
187187
}
188188
gen.mov(qword[contextPointer + HOST_REG_CACHE_OFFSET(0)], runningPointer); // Backup running pointer
189-
gen.mov(runningPointer, (uintptr_t)PCSX::g_system->runningPtr()); // Load pointer to "running" variable
190189

191190
// Allocate shadow stack space on Windows
192191
if constexpr (isWindows()) {
@@ -202,8 +201,12 @@ void DynaRecCPU::emitDispatcher() {
202201

203202
// Poll events
204203
emitMemberFunctionCall(&PCSX::R3000Acpu::branchTest, this);
204+
gen.mov(runningPointer, (uintptr_t)PCSX::g_system->runningPtr()); // Load pointer to "running" variable
205205
gen.test(Xbyak::util::byte[runningPointer], 1); // Check if PCSX::g_system->running is true
206206
gen.jz(done); // If it's not, return
207+
gen.mov(runningPointer, (uintptr_t)PCSX::g_system->quittingPtr()); // Load pointer to "quitting" variable
208+
gen.test(Xbyak::util::byte[runningPointer], 1); // Check if PCSX::g_system->running is true
209+
gen.jnz(done); // If it is, return
207210
emitBlockLookup(); // Otherwise, look up next block
208211

209212
gen.align(16);

src/core/system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class System {
168168
return m_running && !m_quitting;
169169
}
170170
const bool *runningPtr() { return &m_running; }
171+
const bool *quittingPtr() { return &m_quitting; }
171172
bool quitting() { return m_quitting; }
172173
int exitCode() { return m_exitCode; }
173174
bool emergencyExit() { return m_emergencyExit; }

0 commit comments

Comments
 (0)