Permalink
Browse files

irjit: Skip preloading blocks with jump to 0.

These will be changed before executing anyway.
  • Loading branch information...
unknownbrackets committed Jan 7, 2018
1 parent cc8e9a9 commit 97674b80bddc07f26308803892e28818a19bfba7
@@ -295,11 +295,12 @@ void IRFrontend::Comp_Jump(MIPSOpcode op) {
// Might be a stubbed address or something?
if (!Memory::IsValidAddress(targetAddr)) {
if (js.nextExit == 0) {
// If preloading, flush - this block will likely be fixed later.
if (js.preloading)
js.cancel = true;
else
ERROR_LOG_REPORT(JIT, "Jump to invalid address: %08x", targetAddr);
} else {
js.compiling = false;
}
js.compiling = false;
// TODO: Mark this block dirty or something? May be indication it will be changed by imports.
return;
}
@@ -219,8 +219,9 @@ MIPSOpcode IRFrontend::GetOffsetInstruction(int offset) {
return Memory::Read_Instruction(GetCompilerPC() + 4 * offset);
}
void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes) {
void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload) {
js.cancel = false;
js.preloading = preload;
js.blockStart = em_address;
js.compilerPC = em_address;
js.lastContinuedPC = 0;
@@ -246,6 +247,11 @@ void IRFrontend::DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &m
js.numInstructions++;
}
if (js.cancel) {
// Clear the instructions to signal this was not compiled.
ir.Clear();
}
mipsBytes = js.compilerPC - em_address;
IRWriter simplified;
@@ -88,7 +88,7 @@ class IRFrontend : public MIPSFrontendInterface {
void DoState(PointerWrap &p);
bool CheckRounding(u32 blockAddress); // returns true if we need a do-over
void DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes);
void DoJit(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload);
void EatPrefix() override {
js.EatPrefix();
View
@@ -98,14 +98,19 @@ void IRJit::Compile(u32 em_address) {
}
bool IRJit::CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload) {
frontend_.DoJit(em_address, instructions, mipsBytes, preload);
if (instructions.empty()) {
_dbg_assert_(JIT, preload);
// We return true when preloading so it doesn't abort.
return preload;
}
int block_num = blocks_.AllocateBlock(em_address);
if ((block_num & ~MIPS_EMUHACK_VALUE_MASK) != 0) {
// Out of block numbers. Caller will handle.
return false;
}
frontend_.DoJit(em_address, instructions, mipsBytes);
IRBlock *b = blocks_.GetBlock(block_num);
b->SetInstructions(instructions);
b->SetOriginalSize(mipsBytes);
@@ -56,15 +56,6 @@ namespace MIPSComp {
AFTER_MEMCHECK_CLEANUP = 0x04,
};
JitState()
: hasSetRounding(0),
lastSetRounding(0),
currentRoundingFunc(nullptr),
startDefaultPrefix(true),
prefixSFlag(PREFIX_UNKNOWN),
prefixTFlag(PREFIX_UNKNOWN),
prefixDFlag(PREFIX_UNKNOWN) {}
u32 compilerPC;
u32 blockStart;
u32 lastContinuedPC;
@@ -78,20 +69,21 @@ namespace MIPSComp {
int numInstructions;
bool compiling; // TODO: get rid of this in favor of using analysis results to determine end of block
bool hadBreakpoints;
bool preloading = false;
JitBlock *curBlock;
u8 hasSetRounding;
u8 lastSetRounding;
const u8 *currentRoundingFunc;
u8 hasSetRounding = 0;
u8 lastSetRounding = 0;
const u8 *currentRoundingFunc = nullptr;
// VFPU prefix magic
bool startDefaultPrefix;
bool startDefaultPrefix = true;
u32 prefixS;
u32 prefixT;
u32 prefixD;
PrefixState prefixSFlag;
PrefixState prefixTFlag;
PrefixState prefixDFlag;
PrefixState prefixSFlag = PREFIX_UNKNOWN;
PrefixState prefixTFlag = PREFIX_UNKNOWN;
PrefixState prefixDFlag = PREFIX_UNKNOWN;
void PrefixStart() {
if (startDefaultPrefix) {

0 comments on commit 97674b8

Please sign in to comment.