mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: generate an exception when recompilation failed
Avoid the cost of checking -1 for a very rare case. It misses currently a good fallback
This commit is contained in:
parent
395b4c25f3
commit
796f831296
|
@ -43,6 +43,12 @@ namespace Exception
|
||||||
public:
|
public:
|
||||||
explicit CancelInstruction() { }
|
explicit CancelInstruction() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FailedToAllocateRegister
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit FailedToAllocateRegister() { }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -133,9 +133,9 @@ int _getFreeXMMreg()
|
||||||
_freeXMMreg(tempi);
|
_freeXMMreg(tempi);
|
||||||
return 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) {
|
int _allocTempXMMreg(XMMSSEType type, int xmmreg) {
|
||||||
|
@ -144,9 +144,6 @@ int _allocTempXMMreg(XMMSSEType type, int xmmreg) {
|
||||||
else
|
else
|
||||||
_freeXMMreg(xmmreg);
|
_freeXMMreg(xmmreg);
|
||||||
|
|
||||||
if (xmmreg == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
xmmregs[xmmreg].type = XMMTYPE_TEMP;
|
xmmregs[xmmreg].type = XMMTYPE_TEMP;
|
||||||
xmmregs[xmmreg].needed = 1;
|
xmmregs[xmmreg].needed = 1;
|
||||||
|
@ -194,9 +191,6 @@ int _allocVFtoXMMreg(VURegs *VU, int xmmreg, int vfreg, int mode) {
|
||||||
else
|
else
|
||||||
_freeXMMreg(xmmreg);
|
_freeXMMreg(xmmreg);
|
||||||
|
|
||||||
if (xmmreg == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
g_xmmtypes[xmmreg] = XMMT_FPS;
|
g_xmmtypes[xmmreg] = XMMT_FPS;
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
xmmregs[xmmreg].type = XMMTYPE_VFREG;
|
xmmregs[xmmreg].type = XMMTYPE_VFREG;
|
||||||
|
@ -279,9 +273,6 @@ int _allocACCtoXMMreg(VURegs *VU, int xmmreg, int mode) {
|
||||||
else
|
else
|
||||||
_freeXMMreg(xmmreg);
|
_freeXMMreg(xmmreg);
|
||||||
|
|
||||||
if (xmmreg == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
g_xmmtypes[xmmreg] = XMMT_FPS;
|
g_xmmtypes[xmmreg] = XMMT_FPS;
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
xmmregs[xmmreg].type = XMMTYPE_ACC;
|
xmmregs[xmmreg].type = XMMTYPE_ACC;
|
||||||
|
@ -322,8 +313,8 @@ int _allocFPtoXMMreg(int xmmreg, int fpreg, int mode) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmmreg == -1) xmmreg = _getFreeXMMreg();
|
if (xmmreg == -1)
|
||||||
if (xmmreg == -1) return -1;
|
xmmreg = _getFreeXMMreg();
|
||||||
|
|
||||||
g_xmmtypes[xmmreg] = XMMT_FPS;
|
g_xmmtypes[xmmreg] = XMMT_FPS;
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
|
@ -388,8 +379,8 @@ int _allocGPRtoXMMreg(int xmmreg, int gprreg, int mode)
|
||||||
g_cpuHasConstReg &= ~(1<<gprreg);
|
g_cpuHasConstReg &= ~(1<<gprreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xmmreg == -1) xmmreg = _getFreeXMMreg();
|
if (xmmreg == -1)
|
||||||
if (xmmreg == -1) return -1;
|
xmmreg = _getFreeXMMreg();
|
||||||
|
|
||||||
g_xmmtypes[xmmreg] = XMMT_INT;
|
g_xmmtypes[xmmreg] = XMMT_INT;
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
|
@ -468,8 +459,6 @@ int _allocFPACCtoXMMreg(int xmmreg, int mode)
|
||||||
|
|
||||||
if (xmmreg == -1)
|
if (xmmreg == -1)
|
||||||
xmmreg = _getFreeXMMreg();
|
xmmreg = _getFreeXMMreg();
|
||||||
if (xmmreg == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
g_xmmtypes[xmmreg] = XMMT_FPS;
|
g_xmmtypes[xmmreg] = XMMT_FPS;
|
||||||
xmmregs[xmmreg].inuse = 1;
|
xmmregs[xmmreg].inuse = 1;
|
||||||
|
|
|
@ -155,8 +155,7 @@ int _getFreeX86reg(int mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
pxFailDev( "x86 register allocation error" );
|
pxFailDev( "x86 register allocation error" );
|
||||||
|
throw Exception::FailedToAllocateRegister();
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _flushCachedRegs()
|
void _flushCachedRegs()
|
||||||
|
@ -311,9 +310,6 @@ int _allocX86reg(int x86reg, int type, int reg, int mode)
|
||||||
else
|
else
|
||||||
_freeX86reg(x86reg);
|
_freeX86reg(x86reg);
|
||||||
|
|
||||||
if (x86reg == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
x86regs[x86reg].type = type;
|
x86regs[x86reg].type = type;
|
||||||
x86regs[x86reg].reg = reg;
|
x86regs[x86reg].reg = reg;
|
||||||
x86regs[x86reg].mode = mode;
|
x86regs[x86reg].mode = mode;
|
||||||
|
@ -545,7 +541,7 @@ int _getFreeMMXreg()
|
||||||
}
|
}
|
||||||
|
|
||||||
pxFailDev( "mmx register allocation error" );
|
pxFailDev( "mmx register allocation error" );
|
||||||
return -1;
|
throw Exception::FailedToAllocateRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
int _allocMMXreg(int mmxreg, int reg, int mode)
|
int _allocMMXreg(int mmxreg, int reg, int mode)
|
||||||
|
@ -586,8 +582,8 @@ int _allocMMXreg(int mmxreg, int reg, int mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmxreg == -1) mmxreg = _getFreeMMXreg();
|
if (mmxreg == -1)
|
||||||
if (mmxreg == -1) return -1;
|
mmxreg = _getFreeMMXreg();
|
||||||
|
|
||||||
mmxregs[mmxreg].inuse = 1;
|
mmxregs[mmxreg].inuse = 1;
|
||||||
mmxregs[mmxreg].reg = reg;
|
mmxregs[mmxreg].reg = reg;
|
||||||
|
|
|
@ -1476,7 +1476,20 @@ void recompileNextInstruction(int delayslot)
|
||||||
else {
|
else {
|
||||||
//If the COP0 DIE bit is disabled, cycles should be doubled.
|
//If the COP0 DIE bit is disabled, cycles should be doubled.
|
||||||
s_nBlockCycles += opcode.cycles * (2 - ((cpuRegs.CP0.n.Config >> 18) & 0x1));
|
s_nBlockCycles += opcode.cycles * (2 - ((cpuRegs.CP0.n.Config >> 18) & 0x1));
|
||||||
|
try {
|
||||||
opcode.recompile();
|
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 ) {
|
if( !delayslot ) {
|
||||||
|
|
Loading…
Reference in New Issue