mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
SafeMem: Remove the "far" optimization that saves 3 bytes sometimes but is really dangerous and not worth the complexity.
This commit is contained in:
parent
ee6086c0f6
commit
884aef6603
4 changed files with 2 additions and 22 deletions
|
@ -162,7 +162,6 @@ namespace MIPSComp {
|
|||
|
||||
{
|
||||
JitSafeMem safe(this, rs, offset, ~3);
|
||||
safe.SetFar();
|
||||
OpArg src;
|
||||
if (safe.PrepareRead(src, 4))
|
||||
{
|
||||
|
|
|
@ -252,7 +252,6 @@ void Jit::Comp_SV(MIPSOpcode op) {
|
|||
fpr.MapRegV(vt, MAP_DIRTY | MAP_NOINIT);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg src;
|
||||
if (safe.PrepareRead(src, 4)) {
|
||||
MOVSS(fpr.VX(vt), safe.NextFastAddress(0));
|
||||
|
@ -274,7 +273,6 @@ void Jit::Comp_SV(MIPSOpcode op) {
|
|||
fpr.MapRegV(vt, 0);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg dest;
|
||||
if (safe.PrepareWrite(dest, 4)) {
|
||||
MOVSS(safe.NextFastAddress(0), fpr.VX(vt));
|
||||
|
@ -391,7 +389,6 @@ void Jit::Comp_SVQ(MIPSOpcode op) {
|
|||
|
||||
if (fpr.TryMapRegsVS(vregs, V_Quad, MAP_NOINIT | MAP_DIRTY)) {
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg src;
|
||||
if (safe.PrepareRead(src, 16)) {
|
||||
// Should be safe, since lv.q must be aligned, but let's try to avoid crashing in safe mode.
|
||||
|
@ -421,7 +418,6 @@ void Jit::Comp_SVQ(MIPSOpcode op) {
|
|||
fpr.MapRegsV(vregs, V_Quad, MAP_DIRTY | MAP_NOINIT);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg src;
|
||||
if (safe.PrepareRead(src, 16)) {
|
||||
// Just copy 4 words the easiest way while not wasting registers.
|
||||
|
@ -454,7 +450,6 @@ void Jit::Comp_SVQ(MIPSOpcode op) {
|
|||
|
||||
if (fpr.TryMapRegsVS(vregs, V_Quad, 0)) {
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg dest;
|
||||
if (safe.PrepareWrite(dest, 16)) {
|
||||
// Should be safe, since sv.q must be aligned, but let's try to avoid crashing in safe mode.
|
||||
|
@ -482,7 +477,6 @@ void Jit::Comp_SVQ(MIPSOpcode op) {
|
|||
fpr.MapRegsV(vregs, V_Quad, 0);
|
||||
|
||||
JitSafeMem safe(this, rs, imm);
|
||||
safe.SetFar();
|
||||
OpArg dest;
|
||||
if (safe.PrepareWrite(dest, 16)) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
|
@ -53,8 +53,6 @@ void JitMemCheckCleanup()
|
|||
JitSafeMem::JitSafeMem(Jit *jit, MIPSGPReg raddr, s32 offset, u32 alignMask)
|
||||
: jit_(jit), raddr_(raddr), offset_(offset), needsCheck_(false), needsSkip_(false), alignMask_(alignMask)
|
||||
{
|
||||
// This makes it more instructions, so let's play it safe and say we need a far jump.
|
||||
far_ = !g_Config.bIgnoreBadMemAccess || !CBreakPoints::GetMemChecks().empty();
|
||||
// Mask out the kernel RAM bit, because we'll end up with a negative offset to MEMBASEREG.
|
||||
if (jit_->gpr.IsImm(raddr_))
|
||||
iaddr_ = (jit_->gpr.GetImm(raddr_) + offset_) & 0x7FFFFFFF;
|
||||
|
@ -70,12 +68,6 @@ JitSafeMem::JitSafeMem(Jit *jit, MIPSGPReg raddr, s32 offset, u32 alignMask)
|
|||
jit_->gpr.MapReg(raddr_, true, false);
|
||||
}
|
||||
|
||||
void JitSafeMem::SetFar()
|
||||
{
|
||||
_dbg_assert_msg_(JIT, !needsSkip_, "Sorry, you need to call SetFar() earlier.");
|
||||
far_ = true;
|
||||
}
|
||||
|
||||
bool JitSafeMem::PrepareWrite(OpArg &dest, int size)
|
||||
{
|
||||
size_ = size;
|
||||
|
@ -222,7 +214,7 @@ OpArg JitSafeMem::PrepareMemoryOpArg(MemoryOpType type)
|
|||
void JitSafeMem::PrepareSlowAccess()
|
||||
{
|
||||
// Skip the fast path (which the caller wrote just now.)
|
||||
skip_ = jit_->J(far_);
|
||||
skip_ = jit_->J(true);
|
||||
needsSkip_ = true;
|
||||
jit_->SetJumpTarget(tooLow_);
|
||||
jit_->SetJumpTarget(tooHigh_);
|
||||
|
|
|
@ -29,8 +29,6 @@ class JitSafeMem {
|
|||
public:
|
||||
JitSafeMem(Jit *jit, MIPSGPReg raddr, s32 offset, u32 alignMask = 0xFFFFFFFF);
|
||||
|
||||
static void Init(Jit *jit);
|
||||
|
||||
// Emit code necessary for a memory write, returns true if MOV to dest is needed.
|
||||
bool PrepareWrite(Gen::OpArg &dest, int size);
|
||||
// Emit code proceeding a slow write call, returns true if slow write is needed.
|
||||
|
@ -54,8 +52,6 @@ public:
|
|||
// Cleans up final code for the memory access.
|
||||
void Finish();
|
||||
|
||||
// Use this before anything else if you're gonna use the below.
|
||||
void SetFar();
|
||||
// WARNING: Only works for non-GPR. Do not use for reads into GPR.
|
||||
Gen::OpArg NextFastAddress(int suboffset);
|
||||
// WARNING: Only works for non-GPR. Do not use for reads into GPR.
|
||||
|
@ -83,7 +79,6 @@ private:
|
|||
int size_;
|
||||
bool needsCheck_;
|
||||
bool needsSkip_;
|
||||
bool far_;
|
||||
bool fast_;
|
||||
u32 alignMask_;
|
||||
u32 iaddr_;
|
||||
|
@ -124,4 +119,4 @@ private:
|
|||
ThunkManager *thunks_;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue