Skip to content

Commit

Permalink
Oops, forgot about proxy blocks for replace jal.
Browse files Browse the repository at this point in the history
Also fix a crash when they are used.
  • Loading branch information
unknownbrackets committed Apr 17, 2014
1 parent c6da687 commit dc39e75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Core/MIPS/JitCommon/JitBlockCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ void JitBlockCache::ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, cons
}
b.exitAddress[0] = rootAddress;
b.blockNum = num_blocks_;
if (!b.proxyFor) {
b.proxyFor = new std::vector<u32>();
}
b.SetPureProxy(); // flag as pure proxy block.

// Make binary searches and stuff work ok
Expand Down
5 changes: 3 additions & 2 deletions Core/MIPS/JitCommon/JitBlockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ struct JitBlock {
std::vector<u32> *proxyFor;

bool IsPureProxy() const {
return originalFirstOpcode.encoding == 0;
return originalFirstOpcode.encoding == 0x68FF0000;
}
void SetPureProxy() {
originalFirstOpcode.encoding = 0;
// Magic number that won't be a real opcode.
originalFirstOpcode.encoding = 0x68FF0000;
}
};

Expand Down
18 changes: 8 additions & 10 deletions Core/MIPS/x86/Jit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,24 +445,22 @@ bool Jit::ReplaceJalTo(u32 dest) {
MIPSReplaceFunc repl = entry->jitReplaceFunc;
int cycles = (this->*repl)();
js.downcountAmount += cycles;
js.compilerPC += 4;
// No writing exits, keep going!

// Add a trigger so that if the inlined code changes, we invalidate this block.
// TODO: Correctly determine the size of this block.
blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr());
return true;
} else {
gpr.SetImm(MIPS_REG_RA, js.compilerPC + 8);
CompileDelaySlot(DELAYSLOT_NICE);
FlushAll();
ABI_CallFunction(entry->replaceFunc);
SUB(32, M(&currentMIPS->downcount), R(EAX));
js.downcountAmount = 0; // we just subtracted most of it
js.compilerPC += 4;
js.compiling = true;
return true;
}

js.compilerPC += 4;
// No writing exits, keep going!

// Add a trigger so that if the inlined code changes, we invalidate this block.
// TODO: Correctly determine the size of this block.
blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr());
return true;
}

void Jit::Comp_ReplacementFunc(MIPSOpcode op)
Expand Down

0 comments on commit dc39e75

Please sign in to comment.