Merge pull request #16233 from unknownbrackets/jit-clear

jit: Ignore zero byte icache invalidates
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2022-10-16 09:42:43 +02:00
commit 7d53606ec1
9 files changed
+33 -24

No files matched your search

+4 -3
View File
@@ -233,8 +233,9 @@ static int Replace_memcpy16() {
bool skip = false;
// Some games use memcpy on executable code. We need to flush emuhack ops.
currentMIPS->InvalidateICache(srcPtr, bytes);
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0) {
if (bytes != 0)
currentMIPS->InvalidateICache(srcPtr, bytes);
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0 && bytes != 0) {
if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) {
skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes);
}
@@ -305,7 +306,7 @@ static int Replace_memmove() {
bool skip = false;
// Some games use memcpy on executable code. We need to flush emuhack ops.
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0) {
if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0 && bytes != 0) {
currentMIPS->InvalidateICache(srcPtr, bytes);
if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) {
skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes);
+1 -1
View File
@@ -49,7 +49,7 @@ static int __DmacMemcpy(u32 dst, u32 src, u32 size) {
if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) {
skip = gpu->PerformMemoryCopy(dst, src, size);
}
if (!skip) {
if (!skip && size != 0) {
currentMIPS->InvalidateICache(src, size);
if (MemBlockInfoDetailed(size)) {
const std::string tag = GetMemWriteTagAt("DmacMemcpy/", src, size);
+2 -1
View File
@@ -392,7 +392,8 @@ int sceKernelDcacheInvalidateRange(u32 addr, int size)
int sceKernelIcacheInvalidateRange(u32 addr, int size) {
DEBUG_LOG(CPU, "sceKernelIcacheInvalidateRange(%08x, %i)", addr, size);
currentMIPS->InvalidateICache(addr, size);
if (size != 0)
currentMIPS->InvalidateICache(addr, size);
return 0;
}
+2 -1
View File
@@ -624,7 +624,8 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size)
DEBUG_LOG(SCEKERNEL, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size);
// Some games copy from executable code. We need to flush emuhack ops.
currentMIPS->InvalidateICache(src, size);
if (size != 0)
currentMIPS->InvalidateICache(src, size);
bool skip = false;
if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) {
+4 -3
View File
@@ -182,9 +182,10 @@ void ArmJit::ClearCache()
GenerateFixedCode();
}
void ArmJit::InvalidateCacheAt(u32 em_address, int length)
{
blocks.InvalidateICache(em_address, length);
void ArmJit::InvalidateCacheAt(u32 em_address, int length) {
if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {
blocks.InvalidateICache(em_address, length);
}
}
void ArmJit::EatInstruction(MIPSOpcode op) {
+3 -1
View File
@@ -180,7 +180,9 @@ void Arm64Jit::ClearCache() {
}
void Arm64Jit::InvalidateCacheAt(u32 em_address, int length) {
blocks.InvalidateICache(em_address, length);
if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {
blocks.InvalidateICache(em_address, length);
}
}
void Arm64Jit::EatInstruction(MIPSOpcode op) {
+9 -8
View File
@@ -366,14 +366,15 @@ void MIPSState::ProcessPendingClears() {
void MIPSState::InvalidateICache(u32 address, int length) {
// Only really applies to jit.
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
if (MIPSComp::jit) {
if (coreState == CORE_RUNNING || insideJit) {
pendingClears.emplace_back(address, length);
hasPendingClears = true;
CoreTiming::ForceCheck();
} else {
MIPSComp::jit->InvalidateCacheAt(address, length);
}
if (!MIPSComp::jit || length == 0)
return;
if (coreState == CORE_RUNNING || insideJit) {
pendingClears.emplace_back(address, length);
hasPendingClears = true;
CoreTiming::ForceCheck();
} else {
MIPSComp::jit->InvalidateCacheAt(address, length);
}
}
+4 -3
View File
@@ -97,9 +97,10 @@ void MipsJit::ClearCache()
//GenerateFixedCode();
}
void MipsJit::InvalidateCacheAt(u32 em_address, int length)
{
blocks.InvalidateICache(em_address, length);
void MipsJit::InvalidateCacheAt(u32 em_address, int length) {
if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {
blocks.InvalidateICache(em_address, length);
}
}
void MipsJit::EatInstruction(MIPSOpcode op) {
+4 -3
View File
@@ -98,9 +98,10 @@ void FakeJit::ClearCache()
//GenerateFixedCode();
}
void FakeJit::InvalidateCacheAt(u32 em_address, int length)
{
blocks.InvalidateICache(em_address, length);
void FakeJit::InvalidateCacheAt(u32 em_address, int length) {
if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) {
blocks.InvalidateICache(em_address, length);
}
}
void FakeJit::EatInstruction(MIPSOpcode op) {