From 7f795d25aa50610dad1dc2cd61d22658c59ad900 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 26 Oct 2020 22:07:52 +1000 Subject: [PATCH] CPU/Recompiler: Don't try fastmem for RAM mirrors --- src/core/bus.cpp | 23 +++++++++++-------- .../cpu_recompiler_code_generator_generic.cpp | 8 ++++++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/core/bus.cpp b/src/core/bus.cpp index 5edb10c7c..ac13f931d 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -314,28 +314,31 @@ void UpdateFastmemViews(bool enabled, bool isolate_cache) { // KUSEG - cached MapRAM(0x00000000, !isolate_cache); - //MapRAM(0x00200000, !isolate_cache); - //MapRAM(0x00400000, !isolate_cache); - //MapRAM(0x00600000, !isolate_cache); + // MapRAM(0x00200000, !isolate_cache); + // MapRAM(0x00400000, !isolate_cache); + // MapRAM(0x00600000, !isolate_cache); // KSEG0 - cached MapRAM(0x80000000, !isolate_cache); - //MapRAM(0x80200000, !isolate_cache); - //MapRAM(0x80400000, !isolate_cache); - //MapRAM(0x80600000, !isolate_cache); + // MapRAM(0x80200000, !isolate_cache); + // MapRAM(0x80400000, !isolate_cache); + // MapRAM(0x80600000, !isolate_cache); } // KSEG1 - uncached MapRAM(0xA0000000, true); - //MapRAM(0xA0200000, true); - //MapRAM(0xA0400000, true); - //MapRAM(0xA0600000, true); + // MapRAM(0xA0200000, true); + // MapRAM(0xA0400000, true); + // MapRAM(0xA0600000, true); } bool CanUseFastmemForAddress(VirtualMemoryAddress address) { const PhysicalMemoryAddress paddr = address & CPU::PHYSICAL_MEMORY_ADDRESS_MASK; - return IsRAMAddress(paddr); + + // Currently since we don't map the mirrors, don't use fastmem for them. + // This is because the swapping of page code bits for SMC is too expensive. + return (paddr < RAM_SIZE); } bool IsRAMCodePage(u32 index) diff --git a/src/core/cpu_recompiler_code_generator_generic.cpp b/src/core/cpu_recompiler_code_generator_generic.cpp index f03746ca8..ce64e22f7 100644 --- a/src/core/cpu_recompiler_code_generator_generic.cpp +++ b/src/core/cpu_recompiler_code_generator_generic.cpp @@ -42,9 +42,15 @@ Value CodeGenerator::EmitLoadGuestMemory(const CodeBlockInstruction& cbi, const Value result = m_register_cache.AllocateScratch(size); if (g_settings.IsUsingFastmem() && Bus::IsRAMAddress(static_cast(address.constant_value))) - EmitLoadGuestRAMFastmem(address, size, result); + { + // have to mask away the high bits for mirrors, since we don't map them in fastmem + EmitLoadGuestRAMFastmem(Value::FromConstantU32(static_cast(address.constant_value) & Bus::RAM_MASK), size, + result); + } else + { EmitLoadGlobal(result.GetHostRegister(), size, ptr); + } m_delayed_cycles_add += read_ticks; return result;