Merge pull request #356 from Sonicadvance1/Fix-MMUAnalyst
Fixes games that use the MMU to page in code(Rogue Leader).
This commit is contained in:
commit
c4e60d5353
|
@ -406,9 +406,6 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
{
|
{
|
||||||
int blockSize = code_buf->GetSize();
|
int blockSize = code_buf->GetSize();
|
||||||
|
|
||||||
// Memory exception on instruction fetch
|
|
||||||
bool memory_exception = false;
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
||||||
{
|
{
|
||||||
// Comment out the following to disable breakpoints (speed-up)
|
// Comment out the following to disable breakpoints (speed-up)
|
||||||
|
@ -420,21 +417,6 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (em_address == 0)
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bMMU && (em_address & JIT_ICACHE_VMEM_BIT))
|
|
||||||
{
|
|
||||||
if (!Memory::TranslateAddress(em_address, Memory::FLAG_OPCODE))
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
js.firstFPInstructionFound = false;
|
js.firstFPInstructionFound = false;
|
||||||
js.isLastInstruction = false;
|
js.isLastInstruction = false;
|
||||||
js.blockStart = em_address;
|
js.blockStart = em_address;
|
||||||
|
@ -448,10 +430,8 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
u32 nextPC = em_address;
|
u32 nextPC = em_address;
|
||||||
// Analyze the block, collect all instructions it is made of (including inlining,
|
// Analyze the block, collect all instructions it is made of (including inlining,
|
||||||
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
||||||
if (!memory_exception)
|
|
||||||
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
||||||
|
|
||||||
|
|
||||||
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
||||||
|
|
||||||
const u8 *start = AlignCode4(); // TODO: Test if this or AlignCode16 make a difference from GetCodePtr
|
const u8 *start = AlignCode4(); // TODO: Test if this or AlignCode16 make a difference from GetCodePtr
|
||||||
|
@ -678,7 +658,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memory_exception)
|
if (code_block.m_memory_exception)
|
||||||
{
|
{
|
||||||
// Address of instruction could not be translated
|
// Address of instruction could not be translated
|
||||||
MOV(32, M(&NPC), Imm32(js.compilerPC));
|
MOV(32, M(&NPC), Imm32(js.compilerPC));
|
||||||
|
|
|
@ -502,9 +502,6 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
{
|
{
|
||||||
int blockSize = code_buf->GetSize();
|
int blockSize = code_buf->GetSize();
|
||||||
|
|
||||||
// Memory exception on instruction fetch
|
|
||||||
bool memory_exception = false;
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
||||||
{
|
{
|
||||||
// Comment out the following to disable breakpoints (speed-up)
|
// Comment out the following to disable breakpoints (speed-up)
|
||||||
|
@ -516,21 +513,6 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (em_address == 0)
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bMMU && (em_address & JIT_ICACHE_VMEM_BIT))
|
|
||||||
{
|
|
||||||
if (!Memory::TranslateAddress(em_address, Memory::FLAG_OPCODE))
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
js.isLastInstruction = false;
|
js.isLastInstruction = false;
|
||||||
js.blockStart = em_address;
|
js.blockStart = em_address;
|
||||||
js.fifoBytesThisBlock = 0;
|
js.fifoBytesThisBlock = 0;
|
||||||
|
@ -542,7 +524,6 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
u32 nextPC = em_address;
|
u32 nextPC = em_address;
|
||||||
// Analyze the block, collect all instructions it is made of (including inlining,
|
// Analyze the block, collect all instructions it is made of (including inlining,
|
||||||
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
||||||
if (!memory_exception)
|
|
||||||
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
||||||
|
|
||||||
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
||||||
|
@ -690,7 +671,7 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memory_exception)
|
if (code_block.m_memory_exception)
|
||||||
{
|
{
|
||||||
ibuild.EmitISIException(ibuild.EmitIntConst(em_address));
|
ibuild.EmitISIException(ibuild.EmitIntConst(em_address));
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,8 +300,6 @@ void JitArm::Break(UGeckoInstruction inst)
|
||||||
const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlock *b)
|
const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlock *b)
|
||||||
{
|
{
|
||||||
int blockSize = code_buf->GetSize();
|
int blockSize = code_buf->GetSize();
|
||||||
// Memory exception on instruction fetch
|
|
||||||
bool memory_exception = false;
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
||||||
{
|
{
|
||||||
|
@ -316,15 +314,6 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
|
||||||
PanicAlert("ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR);
|
PanicAlert("ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bMMU && (em_address & JIT_ICACHE_VMEM_BIT))
|
|
||||||
{
|
|
||||||
if (!Memory::TranslateAddress(em_address, Memory::FLAG_OPCODE))
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
js.isLastInstruction = false;
|
js.isLastInstruction = false;
|
||||||
js.blockStart = em_address;
|
js.blockStart = em_address;
|
||||||
js.fifoBytesThisBlock = 0;
|
js.fifoBytesThisBlock = 0;
|
||||||
|
@ -335,7 +324,6 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
|
||||||
u32 nextPC = em_address;
|
u32 nextPC = em_address;
|
||||||
// Analyze the block, collect all instructions it is made of (including inlining,
|
// Analyze the block, collect all instructions it is made of (including inlining,
|
||||||
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
||||||
if (!memory_exception)
|
|
||||||
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
||||||
|
|
||||||
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
||||||
|
@ -478,8 +466,9 @@ const u8* JitArm::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (memory_exception)
|
if (code_block.m_memory_exception)
|
||||||
BKPT(0x500);
|
BKPT(0x500);
|
||||||
|
|
||||||
if (code_block.m_broken)
|
if (code_block.m_broken)
|
||||||
{
|
{
|
||||||
printf("Broken Block going to 0x%08x\n", nextPC);
|
printf("Broken Block going to 0x%08x\n", nextPC);
|
||||||
|
|
|
@ -203,8 +203,6 @@ void STACKALIGN JitArmIL::Jit(u32 em_address)
|
||||||
const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlock *b)
|
const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBlock *b)
|
||||||
{
|
{
|
||||||
int blockSize = code_buf->GetSize();
|
int blockSize = code_buf->GetSize();
|
||||||
// Memory exception on instruction fetch
|
|
||||||
bool memory_exception = false;
|
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
if (Core::g_CoreStartupParameter.bEnableDebugging)
|
||||||
{
|
{
|
||||||
|
@ -218,16 +216,6 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
|
||||||
PanicAlert("ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR);
|
PanicAlert("ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::g_CoreStartupParameter.bMMU && (em_address & JIT_ICACHE_VMEM_BIT))
|
|
||||||
{
|
|
||||||
if (!Memory::TranslateAddress(em_address, Memory::FLAG_OPCODE))
|
|
||||||
{
|
|
||||||
// Memory exception occurred during instruction fetch
|
|
||||||
memory_exception = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
js.isLastInstruction = false;
|
js.isLastInstruction = false;
|
||||||
js.blockStart = em_address;
|
js.blockStart = em_address;
|
||||||
js.fifoBytesThisBlock = 0;
|
js.fifoBytesThisBlock = 0;
|
||||||
|
@ -238,7 +226,6 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
|
||||||
u32 nextPC = em_address;
|
u32 nextPC = em_address;
|
||||||
// Analyze the block, collect all instructions it is made of (including inlining,
|
// Analyze the block, collect all instructions it is made of (including inlining,
|
||||||
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
// if that is enabled), reorder instructions for optimal performance, and join joinable instructions.
|
||||||
if (!memory_exception)
|
|
||||||
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
nextPC = analyzer.Analyze(em_address, &code_block, code_buf, blockSize);
|
||||||
|
|
||||||
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
PPCAnalyst::CodeOp *ops = code_buf->codebuffer;
|
||||||
|
@ -334,7 +321,7 @@ const u8* JitArmIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (memory_exception)
|
if (code_block.m_memory_exception)
|
||||||
BKPT(0x500);
|
BKPT(0x500);
|
||||||
|
|
||||||
if (code_block.m_broken)
|
if (code_block.m_broken)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "Core/PowerPC/PPCSymbolDB.h"
|
#include "Core/PowerPC/PPCSymbolDB.h"
|
||||||
#include "Core/PowerPC/PPCTables.h"
|
#include "Core/PowerPC/PPCTables.h"
|
||||||
#include "Core/PowerPC/SignatureDB.h"
|
#include "Core/PowerPC/SignatureDB.h"
|
||||||
#include "Core/PowerPC/Interpreter/Interpreter.h"
|
#include "Core/PowerPC/JitCommon/JitCache.h"
|
||||||
|
|
||||||
// Analyzes PowerPC code in memory to find functions
|
// Analyzes PowerPC code in memory to find functions
|
||||||
// After running, for each function we will know what functions it calls
|
// After running, for each function we will know what functions it calls
|
||||||
|
@ -543,8 +543,26 @@ u32 PPCAnalyzer::Analyze(u32 address, CodeBlock *block, CodeBuffer *buffer, u32
|
||||||
|
|
||||||
// Reset our block state
|
// Reset our block state
|
||||||
block->m_broken = false;
|
block->m_broken = false;
|
||||||
|
block->m_memory_exception = false;
|
||||||
block->m_num_instructions = 0;
|
block->m_num_instructions = 0;
|
||||||
|
|
||||||
|
if (address == 0)
|
||||||
|
{
|
||||||
|
// Memory exception occurred during instruction fetch
|
||||||
|
block->m_memory_exception = true;
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Core::g_CoreStartupParameter.bMMU && (address & JIT_ICACHE_VMEM_BIT))
|
||||||
|
{
|
||||||
|
if (!Memory::TranslateAddress(address, Memory::FLAG_OPCODE))
|
||||||
|
{
|
||||||
|
// Memory exception occurred during instruction fetch
|
||||||
|
block->m_memory_exception = true;
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CodeOp *code = buffer->codebuffer;
|
CodeOp *code = buffer->codebuffer;
|
||||||
|
|
||||||
bool found_exit = false;
|
bool found_exit = false;
|
||||||
|
|
|
@ -124,6 +124,9 @@ struct CodeBlock
|
||||||
|
|
||||||
// Are we a broken block?
|
// Are we a broken block?
|
||||||
bool m_broken;
|
bool m_broken;
|
||||||
|
|
||||||
|
// Did we have a memory_exception?
|
||||||
|
bool m_memory_exception;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PPCAnalyzer
|
class PPCAnalyzer
|
||||||
|
|
Loading…
Reference in New Issue