Make JIT_UNLIMITED_ICACHE always on.

(1) The alternative doesn't compile.
(2) Despite "unlimited" sounding like a hack, it's actually
    significantly more correct then the alternative, which is no
    emulated icache.
(3) Easier to wrap my head around.
This commit is contained in:
comex 2013-10-09 15:23:39 -04:00
parent 715d5ae8a7
commit 86f2e1734a
5 changed files with 1 additions and 73 deletions

View File

@ -85,7 +85,6 @@ void Jit64AsmRoutineManager::Generate()
MOV(32, R(EAX), M(&PowerPC::ppcState.pc));
dispatcherPcInEAX = GetCodePtr();
#ifdef JIT_UNLIMITED_ICACHE
u32 mask = 0;
FixupBranch no_mem;
FixupBranch exit_mem;
@ -142,15 +141,6 @@ void Jit64AsmRoutineManager::Generate()
SetJumpTarget(exit_mem);
if (Core::g_CoreStartupParameter.bWii && (Core::g_CoreStartupParameter.bMMU || Core::g_CoreStartupParameter.bTLBHack))
SetJumpTarget(exit_vmem);
#else
#ifdef _M_IX86
AND(32, R(EAX), Imm32(Memory::MEMVIEW32_MASK));
MOV(32, R(EBX), Imm32((u32)Memory::base));
MOV(32, R(EAX), MComplex(EBX, EAX, SCALE_1, 0));
#else
MOV(32, R(EAX), MComplex(RBX, RAX, SCALE_1, 0));
#endif
#endif
TEST(32, R(EAX), Imm32(0xFC));
FixupBranch notfound = J_CC(CC_NZ);

View File

@ -86,7 +86,6 @@ void JitILAsmRoutineManager::Generate()
MOV(32, R(EAX), M(&PowerPC::ppcState.pc));
dispatcherPcInEAX = GetCodePtr();
#ifdef JIT_UNLIMITED_ICACHE
u32 mask = 0;
FixupBranch no_mem;
FixupBranch exit_mem;
@ -143,15 +142,6 @@ void JitILAsmRoutineManager::Generate()
SetJumpTarget(exit_mem);
if (Core::g_CoreStartupParameter.bWii && (Core::g_CoreStartupParameter.bMMU || Core::g_CoreStartupParameter.bTLBHack))
SetJumpTarget(exit_vmem);
#else
#ifdef _M_IX86
AND(32, R(EAX), Imm32(Memory::MEMVIEW32_MASK));
MOV(32, R(EBX), Imm32((u32)Memory::base));
MOV(32, R(EAX), MComplex(EBX, EAX, SCALE_1, 0));
#else
MOV(32, R(EAX), MComplex(RBX, RAX, SCALE_1, 0));
#endif
#endif
TEST(32, R(EAX), Imm32(0xFC));
FixupBranch notfound = J_CC(CC_NZ);

View File

@ -67,7 +67,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
#endif
blocks = new JitBlock[MAX_NUM_BLOCKS];
blockCodePointers = new const u8*[MAX_NUM_BLOCKS];
#ifdef JIT_UNLIMITED_ICACHE
if (iCache == 0 && iCacheEx == 0 && iCacheVMEM == 0)
{
iCache = new u8[JIT_ICACHE_SIZE];
@ -85,7 +84,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
memset(iCache, JIT_ICACHE_INVALID_BYTE, JIT_ICACHE_SIZE);
memset(iCacheEx, JIT_ICACHE_INVALID_BYTE, JIT_ICACHEEX_SIZE);
memset(iCacheVMEM, JIT_ICACHE_INVALID_BYTE, JIT_ICACHE_SIZE);
#endif
Clear();
}
@ -93,7 +91,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
{
delete[] blocks;
delete[] blockCodePointers;
#ifdef JIT_UNLIMITED_ICACHE
if (iCache != 0)
delete[] iCache;
iCache = 0;
@ -103,7 +100,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
if (iCacheVMEM != 0)
delete[] iCacheVMEM;
iCacheVMEM = 0;
#endif
blocks = 0;
blockCodePointers = 0;
num_blocks = 0;
@ -140,11 +136,9 @@ bool JitBlock::ContainsAddress(u32 em_address)
void JitBaseBlockCache::ClearSafe()
{
#ifdef JIT_UNLIMITED_ICACHE
memset(iCache, JIT_ICACHE_INVALID_BYTE, JIT_ICACHE_SIZE);
memset(iCacheEx, JIT_ICACHE_INVALID_BYTE, JIT_ICACHEEX_SIZE);
memset(iCacheVMEM, JIT_ICACHE_INVALID_BYTE, JIT_ICACHE_SIZE);
#endif
}
/*void JitBaseBlockCache::DestroyBlocksWithFlag(BlockFlag death_flag)
@ -206,7 +200,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
{
blockCodePointers[block_num] = code_ptr;
JitBlock &b = blocks[block_num];
b.originalFirstOpcode = JitInterface::Read_Opcode_JIT(b.originalAddress);
JitInterface::Write_Opcode_JIT(b.originalAddress, (JIT_OPCODE << 26) | block_num);
// Convert the logical address to a physical address for the block map
@ -256,7 +249,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
return blockCodePointers;
}
#ifdef JIT_UNLIMITED_ICACHE
u8* JitBaseBlockCache::GetICache()
{
return iCache;
@ -271,13 +263,11 @@ bool JitBlock::ContainsAddress(u32 em_address)
{
return iCacheVMEM;
}
#endif
int JitBaseBlockCache::GetBlockNumberFromStartAddress(u32 addr)
{
if (!blocks)
return -1;
#ifdef JIT_UNLIMITED_ICACHE
u32 inst;
if (addr & JIT_ICACHE_VMEM_BIT)
{
@ -292,9 +282,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
inst = *(u32*)(iCache + (addr & JIT_ICACHE_MASK));
}
inst = Common::swap32(inst);
#else
u32 inst = Memory::ReadFast32(addr);
#endif
if (inst & 0xfc000000) // definitely not a JIT block
return -1;
if ((int)inst >= num_blocks)
@ -311,16 +298,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
block_numbers->push_back(i);
}
u32 JitBaseBlockCache::GetOriginalFirstOp(int block_num)
{
if (block_num >= num_blocks)
{
//PanicAlert("JitBaseBlockCache::GetOriginalFirstOp - block_num = %u is out of range", block_num);
return block_num;
}
return blocks[block_num].originalFirstOpcode;
}
CompiledCode JitBaseBlockCache::GetCompiledCodeFromBlock(int block_num)
{
return (CompiledCode)blockCodePointers[block_num];
@ -404,12 +381,7 @@ bool JitBlock::ContainsAddress(u32 em_address)
return;
}
b.invalid = true;
#ifdef JIT_UNLIMITED_ICACHE
JitInterface::Write_Opcode_JIT(b.originalAddress, b.originalFirstOpcode?b.originalFirstOpcode:JIT_ICACHE_INVALID_WORD);
#else
if (Memory::ReadFast32(b.originalAddress) == block_num)
Memory::WriteUnchecked_U32(b.originalFirstOpcode, b.originalAddress);
#endif
JitInterface::Write_Opcode_JIT(b.originalAddress, JIT_ICACHE_INVALID_WORD);
UnlinkBlock(block_num);
@ -441,7 +413,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
std::map<pair<u32,u32>, u32>::iterator it1 = block_map.lower_bound(std::make_pair(pAddr, 0)), it2 = it1;
while (it2 != block_map.end() && it2->first.second < pAddr + length)
{
#ifdef JIT_UNLIMITED_ICACHE
JitBlock &b = blocks[it2->second];
if (b.originalAddress & JIT_ICACHE_VMEM_BIT)
{
@ -458,7 +429,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
u32 cacheaddr = b.originalAddress & JIT_ICACHE_MASK;
memset(iCache + cacheaddr, JIT_ICACHE_INVALID_BYTE, 4);
}
#endif
DestroyBlock(it2->second, true);
it2++;
}
@ -468,7 +438,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
}
}
#ifdef JIT_UNLIMITED_ICACHE
// invalidate iCache.
// icbi can be called with any address, so we should check
if ((address & ~JIT_ICACHE_MASK) != 0x80000000 && (address & ~JIT_ICACHE_MASK) != 0x00000000 &&
@ -492,7 +461,6 @@ bool JitBlock::ContainsAddress(u32 em_address)
u32 cacheaddr = address & JIT_ICACHE_MASK;
memset(iCache + cacheaddr, JIT_ICACHE_INVALID_BYTE, length);
}
#endif
}
void JitBlockCache::WriteLinkBlock(u8* location, const u8* address)
{

View File

@ -39,7 +39,6 @@ struct JitBlock
u32 exitAddress[2]; // 0xFFFFFFFF == unknown
u32 originalAddress;
u32 originalFirstOpcode; //to be able to restore
u32 codeSize;
u32 originalSize;
int runCount; // for profiling.
@ -74,11 +73,9 @@ class JitBaseBlockCache
std::multimap<u32, int> links_to;
std::map<std::pair<u32,u32>, u32> block_map; // (end_addr, start_addr) -> number
std::bitset<0x20000000 / 32> valid_block;
#ifdef JIT_UNLIMITED_ICACHE
u8 *iCache;
u8 *iCacheEx;
u8 *iCacheVMEM;
#endif
int MAX_NUM_BLOCKS;
bool RangeIntersect(int s1, int e1, int s2, int e2) const;
@ -93,9 +90,7 @@ class JitBaseBlockCache
public:
JitBaseBlockCache() :
blockCodePointers(0), blocks(0), num_blocks(0),
#ifdef JIT_UNLIMITED_ICACHE
iCache(0), iCacheEx(0), iCacheVMEM(0),
#endif
MAX_NUM_BLOCKS(0) { }
int AllocateBlock(u32 em_address);
void FinalizeBlock(int block_num, bool block_link, const u8 *code_ptr);
@ -112,11 +107,9 @@ public:
JitBlock *GetBlock(int block_num);
int GetNumBlocks() const;
const u8 **GetCodePointers();
#ifdef JIT_UNLIMITED_ICACHE
u8 *GetICache();
u8 *GetICacheEx();
u8 *GetICacheVMEM();
#endif
// Fast way to get a block. Only works on the first ppc instruction of a block.
int GetBlockNumberFromStartAddress(u32 em_address);

View File

@ -241,11 +241,6 @@ namespace JitInterface
}
inst = Common::swap32(inst);
if ((inst & 0xfc000000) == 0)
{
inst = jit->GetBlockCache()->GetOriginalFirstOp(inst);
}
return inst;
}
@ -276,7 +271,6 @@ namespace JitInterface
// The following function is deprecated in favour of FAST_ICACHE
u32 Read_Opcode_JIT_LC(const u32 _Address)
{
#ifdef JIT_UNLIMITED_ICACHE
if ((_Address & ~JIT_ICACHE_MASK) != 0x80000000 && (_Address & ~JIT_ICACHE_MASK) != 0x00000000 &&
(_Address & ~JIT_ICACHE_MASK) != 0x7e000000 && // TLB area
(_Address & ~JIT_ICACHEEX_MASK) != 0x90000000 && (_Address & ~JIT_ICACHEEX_MASK) != 0x10000000)
@ -307,9 +301,6 @@ namespace JitInterface
inst = Memory::ReadUnchecked_U32(_Address);
else
inst = Common::swap32(inst);
#else
u32 inst = Memory::ReadUnchecked_U32(_Address);
#endif
if ((inst & 0xfc000000) == 0)
{
inst = jit->GetBlockCache()->GetOriginalFirstOp(inst);
@ -321,7 +312,6 @@ namespace JitInterface
// We assume that _Address is cached
void Write_Opcode_JIT(const u32 _Address, const u32 _Value)
{
#ifdef JIT_UNLIMITED_ICACHE
if (_Address & JIT_ICACHE_VMEM_BIT)
{
*(u32*)(jit->GetBlockCache()->GetICacheVMEM() + (_Address & JIT_ICACHE_MASK)) = Common::swap32(_Value);
@ -332,9 +322,6 @@ namespace JitInterface
}
else
*(u32*)(jit->GetBlockCache()->GetICache() + (_Address & JIT_ICACHE_MASK)) = Common::swap32(_Value);
#else
Memory::WriteUnchecked_U32(_Value, _Address);
#endif
}