mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-11 08:39:28 +01:00
Merge pull request #7869 from unknownbrackets/jit-minor
Check all jit blocks in sceKernelIcacheInvalidateAll()
This commit is contained in:
commit
f4e0034aef
7 files changed
+41
-11
No files matched your search
+1
-3
@@ -284,9 +284,7 @@ std::vector<std::string> CWCheatEngine::GetCodesList() { //Reads the entire chea
|
||||
}
|
||||
|
||||
void CWCheatEngine::InvalidateICache(u32 addr, int size) {
|
||||
if (MIPSComp::jit) {
|
||||
MIPSComp::jit->GetBlockCache()->InvalidateICache(addr & ~3, size);
|
||||
}
|
||||
currentMIPS->InvalidateICache(addr & ~3, size);
|
||||
}
|
||||
|
||||
void CWCheatEngine::Run() {
|
||||
|
||||
@@ -425,6 +425,8 @@ u32 sceKernelIcacheInvalidateAll()
|
||||
#ifdef LOG_CACHE
|
||||
NOTICE_LOG(CPU, "Icache invalidated - should clear JIT someday");
|
||||
#endif
|
||||
// Note that this doesn't actually fully invalidate all with such a large range.
|
||||
currentMIPS->InvalidateICache(0, 0x3FFFFFFF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -435,6 +437,8 @@ u32 sceKernelIcacheClearAll()
|
||||
NOTICE_LOG(CPU, "Icache cleared - should clear JIT someday");
|
||||
#endif
|
||||
DEBUG_LOG(CPU, "Icache cleared - should clear JIT someday");
|
||||
// Note that this doesn't actually fully invalidate all with such a large range.
|
||||
currentMIPS->InvalidateICache(0, 0x3FFFFFFF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace MIPSComp
|
||||
|
||||
int pos = _POS;
|
||||
int size = _SIZE + 1;
|
||||
u32 mask = (1 << size) - 1;
|
||||
u32 mask = 0xFFFFFFFFUL >> (32 - size);
|
||||
|
||||
// Don't change $zr.
|
||||
if (rt == 0)
|
||||
|
||||
@@ -431,8 +431,7 @@ void Arm64Jit::Comp_Special3(MIPSOpcode op) {
|
||||
|
||||
int pos = _POS;
|
||||
int size = _SIZE + 1;
|
||||
// Workaround for a compiler bug.
|
||||
u32 mask = size == 32 ? 0xFFFFFFFF : (1 << size) - 1;
|
||||
u32 mask = 0xFFFFFFFFUL >> (32 - size);
|
||||
|
||||
// Don't change $zr.
|
||||
if (rt == 0)
|
||||
|
||||
@@ -566,14 +566,21 @@ void JitBlockCache::DestroyBlock(int block_num, bool invalidate) {
|
||||
}
|
||||
|
||||
b->invalid = true;
|
||||
if (Memory::ReadUnchecked_U32(b->originalAddress) == GetEmuHackOpForBlock(block_num).encoding)
|
||||
Memory::Write_Opcode_JIT(b->originalAddress, b->originalFirstOpcode);
|
||||
if (!b->IsPureProxy()) {
|
||||
if (Memory::ReadUnchecked_U32(b->originalAddress) == GetEmuHackOpForBlock(block_num).encoding)
|
||||
Memory::Write_Opcode_JIT(b->originalAddress, b->originalFirstOpcode);
|
||||
}
|
||||
|
||||
// It's not safe to set normalEntry to 0 here, since we use a binary search
|
||||
// that looks at that later to find blocks. Marking it invalid is enough.
|
||||
|
||||
UnlinkBlock(block_num);
|
||||
|
||||
// Don't change the jit code when invalidating a pure proxy block.
|
||||
if (b->IsPureProxy()) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(ARM)
|
||||
|
||||
// Send anyone who tries to run this block back to the dispatcher.
|
||||
@@ -619,6 +626,11 @@ void JitBlockCache::InvalidateICache(u32 address, const u32 length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pAddr == 0 && pEnd >= 0x1FFFFFFF) {
|
||||
InvalidateChangedBlocks();
|
||||
return;
|
||||
}
|
||||
|
||||
// Blocks may start and end in overlapping ways, and destroying one invalidates iterators.
|
||||
// So after destroying one, we start over.
|
||||
do {
|
||||
@@ -640,6 +652,21 @@ void JitBlockCache::InvalidateICache(u32 address, const u32 length) {
|
||||
} while (false);
|
||||
}
|
||||
|
||||
void JitBlockCache::InvalidateChangedBlocks() {
|
||||
// The primary goal of this is to make sure block linking is cleared up.
|
||||
for (int block_num = 0; block_num < num_blocks_; ++block_num) {
|
||||
JitBlock &b = blocks_[block_num];
|
||||
if (b.invalid || b.IsPureProxy())
|
||||
continue;
|
||||
|
||||
const u32 emuhack = GetEmuHackOpForBlock(block_num).encoding;
|
||||
if (Memory::ReadUnchecked_U32(b.originalAddress) != emuhack) {
|
||||
DEBUG_LOG(JIT, "Invalidating changed block at %08x", b.originalAddress);
|
||||
DestroyBlock(block_num, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int JitBlockCache::GetBlockExitSize() {
|
||||
#if defined(ARM)
|
||||
// Will depend on the sequence found to encode the destination address.
|
||||
|
||||
@@ -147,6 +147,7 @@ public:
|
||||
|
||||
// DOES NOT WORK CORRECTLY WITH JIT INLINING
|
||||
void InvalidateICache(u32 address, const u32 length);
|
||||
void InvalidateChangedBlocks();
|
||||
void DestroyBlock(int block_num, bool invalidate);
|
||||
|
||||
// No jit operations may be run between these calls.
|
||||
|
||||
@@ -866,14 +866,15 @@ namespace MIPSInt
|
||||
case 0x0: //ext
|
||||
{
|
||||
int size = _SIZE + 1;
|
||||
R(rt) = (R(rs) >> pos) & ((1<<size) - 1);
|
||||
u32 sourcemask = 0xFFFFFFFFUL >> (32 - size);
|
||||
R(rt) = (R(rs) >> pos) & sourcemask;
|
||||
}
|
||||
break;
|
||||
case 0x4: //ins
|
||||
{
|
||||
int size = (_SIZE + 1) - pos;
|
||||
int sourcemask = (1 << size) - 1;
|
||||
int destmask = sourcemask << pos;
|
||||
u32 sourcemask = 0xFFFFFFFFUL >> (32 - size);
|
||||
u32 destmask = sourcemask << pos;
|
||||
R(rt) = (R(rt) & ~destmask) | ((R(rs)&sourcemask) << pos);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user