Make it possible to have more block exits.

This commit is contained in:
Unknown W. Brackets 2013-08-15 23:23:39 -07:00
parent 64c2ea86c0
commit 14b719a7ac
3 changed files with 21 additions and 13 deletions

View File

@ -137,12 +137,12 @@ int JitBlockCache::AllocateBlock(u32 em_address)
JitBlock &b = blocks[num_blocks];
b.invalid = false;
b.originalAddress = em_address;
b.exitAddress[0] = INVALID_EXIT;
b.exitAddress[1] = INVALID_EXIT;
b.exitPtrs[0] = 0;
b.exitPtrs[1] = 0;
b.linkStatus[0] = false;
b.linkStatus[1] = false;
for (int i = 0; i < MAX_JIT_BLOCK_EXITS; ++i)
{
b.exitAddress[i] = INVALID_EXIT;
b.exitPtrs[i] = 0;
b.linkStatus[i] = false;
}
b.blockNum = num_blocks;
num_blocks++; //commit the current block
return num_blocks - 1;
@ -163,7 +163,7 @@ void JitBlockCache::FinalizeBlock(int block_num, bool block_link)
block_map[std::make_pair(pAddr + 4 * b.originalSize - 1, pAddr)] = block_num;
if (block_link)
{
for (int i = 0; i < 2; i++)
for (int i = 0; i < MAX_JIT_BLOCK_EXITS; i++)
{
if (b.exitAddress[i] != INVALID_EXIT)
links_to.insert(std::pair<u32, int>(b.exitAddress[i], block_num));
@ -228,7 +228,7 @@ u32 JitBlockCache::GetEmuHackOpForBlock(int blockNum) const {
int JitBlockCache::GetBlockNumberFromStartAddress(u32 addr)
{
if (!blocks)
return -1;
return -1;
u32 inst = Memory::Read_U32(addr);
int bl = GetBlockNumberFromEmuHackOp(inst);
if (bl < 0)
@ -262,7 +262,7 @@ void JitBlockCache::LinkBlockExits(int i)
// This block is dead. Don't relink it.
return;
}
for (int e = 0; e < 2; e++) {
for (int e = 0; e < MAX_JIT_BLOCK_EXITS; e++) {
if (b.exitAddress[e] != INVALID_EXIT && !b.linkStatus[e]) {
int destinationBlock = GetBlockNumberFromStartAddress(b.exitAddress[e]);
if (destinationBlock != -1) {
@ -308,7 +308,7 @@ void JitBlockCache::UnlinkBlock(int i)
return;
for (multimap<u32, int>::iterator iter = ppp.first; iter != ppp.second; ++iter) {
JitBlock &sourceBlock = blocks[iter->second];
for (int e = 0; e < 2; e++)
for (int e = 0; e < MAX_JIT_BLOCK_EXITS; e++)
{
if (sourceBlock.exitAddress[e] == b.originalAddress)
sourceBlock.linkStatus[e] = false;

View File

@ -40,6 +40,12 @@ typedef Gen::XCodeBlock CodeBlock;
#error "Unsupported arch!"
#endif
#if defined(ARM)
const int MAX_JIT_BLOCK_EXITS = 2;
#else
const int MAX_JIT_BLOCK_EXITS = 8;
#endif
// Define this in order to get VTune profile support for the Jit generated code.
// Add the VTune include/lib directories to the project directories to get this to build.
// #define USE_VTUNE
@ -50,8 +56,8 @@ struct JitBlock {
const u8 *checkedEntry;
const u8 *normalEntry;
u8 *exitPtrs[2]; // to be able to rewrite the exit jump
u32 exitAddress[2]; // 0xFFFFFFFF == unknown
u8 *exitPtrs[MAX_JIT_BLOCK_EXITS]; // to be able to rewrite the exit jump
u32 exitAddress[MAX_JIT_BLOCK_EXITS]; // 0xFFFFFFFF == unknown
u32 originalAddress;
u32 originalFirstOpcode; //to be able to restore
@ -60,7 +66,7 @@ struct JitBlock {
u16 blockNum;
bool invalid;
bool linkStatus[2];
bool linkStatus[MAX_JIT_BLOCK_EXITS];
#ifdef USE_VTUNE
char blockName[32];

View File

@ -366,6 +366,8 @@ void Jit::Comp_Generic(u32 op)
void Jit::WriteExit(u32 destination, int exit_num)
{
_dbg_assert_msg_(JIT, exit_num < MAX_JIT_BLOCK_EXITS, "Expected a valid exit_num");
if (!Memory::IsValidAddress(destination)) {
ERROR_LOG_REPORT(JIT, "Trying to write block exit to illegal destination %08x: pc = %08x", destination, currentMIPS->pc);
}