mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
Merge pull request #812 from FioraAeterna/fixundefined
JIT: don't rely on undefined behavior for constant overflow checking
This commit is contained in:
commit
444e47a07a
@ -94,6 +94,7 @@ public:
|
|||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
void GenerateConstantOverflow(bool overflow);
|
void GenerateConstantOverflow(bool overflow);
|
||||||
|
void GenerateConstantOverflow(s64 val);
|
||||||
void GenerateOverflow();
|
void GenerateOverflow();
|
||||||
void FinalizeCarryOverflow(bool oe, bool inv = false);
|
void FinalizeCarryOverflow(bool oe, bool inv = false);
|
||||||
void GetCarryEAXAndClear();
|
void GetCarryEAXAndClear();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Licensed under GPLv2
|
// Licensed under GPLv2
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Core/PowerPC/Jit64/Jit.h"
|
#include "Core/PowerPC/Jit64/Jit.h"
|
||||||
@ -10,6 +11,11 @@
|
|||||||
|
|
||||||
using namespace Gen;
|
using namespace Gen;
|
||||||
|
|
||||||
|
void Jit64::GenerateConstantOverflow(s64 val)
|
||||||
|
{
|
||||||
|
GenerateConstantOverflow(val > std::numeric_limits<s32>::max() || val < std::numeric_limits<s32>::min());
|
||||||
|
}
|
||||||
|
|
||||||
void Jit64::GenerateConstantOverflow(bool overflow)
|
void Jit64::GenerateConstantOverflow(bool overflow)
|
||||||
{
|
{
|
||||||
if (overflow)
|
if (overflow)
|
||||||
@ -925,7 +931,7 @@ void Jit64::subfx(UGeckoInstruction inst)
|
|||||||
}
|
}
|
||||||
if (inst.OE)
|
if (inst.OE)
|
||||||
{
|
{
|
||||||
GenerateConstantOverflow((s64)(i - j) != (s64)i - (s64)j);
|
GenerateConstantOverflow((s64)i - (s64)j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1014,7 +1020,7 @@ void Jit64::mullwx(UGeckoInstruction inst)
|
|||||||
gpr.SetImmediate32(d, i * j);
|
gpr.SetImmediate32(d, i * j);
|
||||||
if (inst.OE)
|
if (inst.OE)
|
||||||
{
|
{
|
||||||
GenerateConstantOverflow((s64)(i*j) != (s64)i * (s64)j);
|
GenerateConstantOverflow((s64)i * (s64)j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1330,7 +1336,7 @@ void Jit64::addx(UGeckoInstruction inst)
|
|||||||
}
|
}
|
||||||
if (inst.OE)
|
if (inst.OE)
|
||||||
{
|
{
|
||||||
GenerateConstantOverflow((s64)(i + j) != (s64)i + (s64)j);
|
GenerateConstantOverflow((s64)i + (s64)j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (gpr.R(a).IsSimpleReg() && gpr.R(b).IsSimpleReg() && !inst.Rc && !inst.OE)
|
else if (gpr.R(a).IsSimpleReg() && gpr.R(b).IsSimpleReg() && !inst.Rc && !inst.OE)
|
||||||
|
Loading…
Reference in New Issue
Block a user