diff --git a/pcsx2/R5900.h b/pcsx2/R5900.h index 1b8057e0a4..2cd890dcfc 100644 --- a/pcsx2/R5900.h +++ b/pcsx2/R5900.h @@ -43,6 +43,12 @@ namespace Exception public: explicit CancelInstruction() { } }; + + class FailedToAllocateRegister + { + public: + explicit FailedToAllocateRegister() { } + }; } // -------------------------------------------------------------------------------------- diff --git a/pcsx2/x86/iCore.cpp b/pcsx2/x86/iCore.cpp index 7df76a2471..14c98d04e8 100644 --- a/pcsx2/x86/iCore.cpp +++ b/pcsx2/x86/iCore.cpp @@ -133,9 +133,9 @@ int _getFreeXMMreg() _freeXMMreg(tempi); return tempi; } - pxFailDev("*PCSX2*: XMM Reg Allocation Error in _getFreeXMMreg()!"); - return -1; + pxFailDev("*PCSX2*: XMM Reg Allocation Error in _getFreeXMMreg()!"); + throw Exception::FailedToAllocateRegister(); } int _allocTempXMMreg(XMMSSEType type, int xmmreg) { @@ -144,9 +144,6 @@ int _allocTempXMMreg(XMMSSEType type, int xmmreg) { else _freeXMMreg(xmmreg); - if (xmmreg == -1) - return -1; - xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_TEMP; xmmregs[xmmreg].needed = 1; @@ -194,9 +191,6 @@ int _allocVFtoXMMreg(VURegs *VU, int xmmreg, int vfreg, int mode) { else _freeXMMreg(xmmreg); - if (xmmreg == -1) - return -1; - g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_VFREG; @@ -279,9 +273,6 @@ int _allocACCtoXMMreg(VURegs *VU, int xmmreg, int mode) { else _freeXMMreg(xmmreg); - if (xmmreg == -1) - return -1; - g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; xmmregs[xmmreg].type = XMMTYPE_ACC; @@ -322,8 +313,8 @@ int _allocFPtoXMMreg(int xmmreg, int fpreg, int mode) { return i; } - if (xmmreg == -1) xmmreg = _getFreeXMMreg(); - if (xmmreg == -1) return -1; + if (xmmreg == -1) + xmmreg = _getFreeXMMreg(); g_xmmtypes[xmmreg] = XMMT_FPS; xmmregs[xmmreg].inuse = 1; @@ -388,8 +379,8 @@ int _allocGPRtoXMMreg(int xmmreg, int gprreg, int mode) g_cpuHasConstReg &= ~(1<> 18) & 0x1)); - opcode.recompile(); + try { + opcode.recompile(); + } catch (Exception::FailedToAllocateRegister&) { + // TODO: fallback to interpreter +#if 0 + iFlushCall(FLUSH_INTERPRETER); + CALLFunc( (uptr)R5900::Interpreter::OpcodeImpl::MMI::PMFHL ); +#endif + // TODO: Free register ? +#if 0 + // _freeXMMregs(); + // _freeMMXregs(); +#endif + } } if( !delayslot ) {