CPU: Pass the MIPSState explicitly where it was already at hand

The JIT backends' calls out of generated code (the MIPS and IR interpreter
fallbacks, and the bad address report) now take the state the backend was
built for instead of reading currentMIPS. Likewise the interpreter's tick
check, the IR dispatcher's Advance, and a couple of debugger helpers.

MIPSState::InitRegisters() no longer sets currentMIPS; the boot paths set it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-20 09:47:48 +02:00
1 parent 2be8d57f8c
commit 5a9cbf007c
20 files changed
+121 -31

No files matched your search

+7 -6
View File
@@ -147,31 +147,31 @@ void IRNativeBackend::NotifyMIPSInterpret(const char *name) {
debugSeenNotCompiled[name]++;
}
void IRNativeBackend::DoMIPSInst(uint32_t value) {
void IRNativeBackend::DoMIPSInst(uint32_t value, MIPSState *mips) {
MIPSOpcode op;
memcpy(&op, &value, sizeof(op));
if constexpr (enableDebugStats)
debugSeenNotCompiled[MIPSGetName(op)]++;
MIPSInterpret(currentMIPS, op);
MIPSInterpret(mips, op);
}
// This is called from IR->JIT implementation to fall back to the IR interpreter for missing ops.
// Not fast.
uint32_t IRNativeBackend::DoIRInst(uint64_t value) {
uint32_t IRNativeBackend::DoIRInst(uint64_t value, MIPSState *mips) {
IRInst inst[2]{};
memcpy(&inst[0], &value, sizeof(value));
if constexpr (enableDebugStats)
debugSeenNotCompiledIR[(uint8_t)inst[0].op]++;
// Doesn't really matter what value it returns as PC.
inst[1].op = IROp::ExitToPC;
return IRInterpret(currentMIPS, &inst[0]);
return IRInterpret(mips, &inst[0]);
}
int IRNativeBackend::ReportBadAddress(uint32_t addr, uint32_t alignment, uint32_t isWrite) {
int IRNativeBackend::ReportBadAddress(uint32_t addr, uint32_t alignment, uint32_t isWrite, MIPSState *mips) {
const auto toss = [&](MemoryExceptionType t) {
Core_MemoryException(addr, alignment, currentMIPS->pc, t);
Core_MemoryException(addr, alignment, mips->pc, t);
return coreState != CORE_RUNNING_CPU ? 1 : 0;
};
@@ -514,6 +514,7 @@ void IRNativeJit::Init(IRNativeBackend &backend) {
backend_ = &backend;
backend_->SetProfiling(profiling_);
debugInterface_.Init(backend_);
backend_->SetMIPSState(mips_);
backend_->GenerateFixedCode(mips_);
// Wanted this to be a reference, but vtbls get in the way. Shouldn't change.